public void UpdateReservedWordsInDialect()
		{
			var reservedDb = new HashedSet<string>();
			var configuration = TestConfigurationHelper.GetDefaultConfiguration();
			var dialect = Dialect.Dialect.GetDialect(configuration.Properties);
			var connectionHelper = new ManagedProviderConnectionHelper(configuration.Properties);
			connectionHelper.Prepare();
			try
			{
				var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection);
				foreach (var rw in metaData.GetReservedWords())
				{
					reservedDb.Add(rw.ToLowerInvariant());
				}
			}
			finally
			{
				connectionHelper.Release();
			}

			var sf = (ISessionFactoryImplementor) configuration.BuildSessionFactory();
			SchemaMetadataUpdater.Update(sf);
			var match = reservedDb.Intersect(sf.Dialect.Keywords);
			Assert.That(match, Is.EquivalentTo(reservedDb));
		}
Пример #2
0
        private static ISet <string> GetReservedWords(IDictionary <string, string> cfgProperties)
        {
            var dialect          = Dialect.Dialect.GetDialect(cfgProperties);
            var connectionHelper = new ManagedProviderConnectionHelper(cfgProperties);

            return(GetReservedWords(dialect, connectionHelper));
        }
		public void CanRetrieveReservedWords()
		{
			var configuration = TestConfigurationHelper.GetDefaultConfiguration();
			var dialect = Dialect.Dialect.GetDialect(configuration.Properties);
			var connectionHelper = new ManagedProviderConnectionHelper(configuration.Properties);
			connectionHelper.Prepare();
			try
			{
				var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection);
				var reserved = metaData.GetReservedWords();
				Assert.That(reserved, Is.Not.Empty);
				Assert.That(reserved, Has.Member("SELECT"));
				Assert.That(reserved, Has.Member("FROM"));
			}
			finally
			{
				connectionHelper.Release();
			}
		}
		public void AutoQuoteTableAndColumnsAtStratupIncludeKeyWordsImport()
		{
			var reservedDb = new HashedSet<string>();
			var configuration = TestConfigurationHelper.GetDefaultConfiguration();
			var dialect = Dialect.Dialect.GetDialect(configuration.Properties);
			var connectionHelper = new ManagedProviderConnectionHelper(configuration.Properties);
			connectionHelper.Prepare();
			try
			{
				var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection);
				foreach (var rw in metaData.GetReservedWords())
				{
					reservedDb.Add(rw.ToLowerInvariant());
				}
			}
			finally
			{
				connectionHelper.Release();
			}

			configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
			configuration.AddResource("NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml",
																GetType().Assembly);
			var sf = (ISessionFactoryImplementor)configuration.BuildSessionFactory();
			var match = reservedDb.Intersect(sf.Dialect.Keywords);
			Assert.That(match, Is.EquivalentTo(reservedDb));
		}
		private static Iesi.Collections.Generic.ISet<string> GetReservedWords(IDictionary<string, string> cfgProperties)
		{
			var dialect = Dialect.Dialect.GetDialect(cfgProperties);
			var connectionHelper = new ManagedProviderConnectionHelper(cfgProperties);
			return GetReservedWords(dialect, connectionHelper);
		}