[pgsqlclient-checkins] SF.net SVN: pgsqlclient: [57] trunk/pgsqlclient/source/PostgreSql/Data/Schema
Status: Inactive
Brought to you by:
carlosga_fb
|
From: <car...@us...> - 2006-03-27 13:04:17
|
Revision: 57 Author: carlosga_fb Date: 2006-03-27 05:04:09 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=57&view=rev Log Message: ----------- ?\194?\183 Added implementation of ViewColumns schema Modified Paths: -------------- trunk/pgsqlclient/source/PostgreSql/Data/Schema/MetaData.xml trunk/pgsqlclient/source/PostgreSql/Data/Schema/PgViewColumns.cs Modified: trunk/pgsqlclient/source/PostgreSql/Data/Schema/MetaData.xml =================================================================== --- trunk/pgsqlclient/source/PostgreSql/Data/Schema/MetaData.xml 2006-03-27 12:45:14 UTC (rev 56) +++ trunk/pgsqlclient/source/PostgreSql/Data/Schema/MetaData.xml 2006-03-27 13:04:09 UTC (rev 57) @@ -516,6 +516,30 @@ <RestrictionDefault>view_name</RestrictionDefault> <RestrictionNumber>3</RestrictionNumber> </Restrictions> + <Restrictions> + <CollectionName>ViewColumns</CollectionName> + <RestrictionName>ViewCatalog</RestrictionName> + <RestrictionDefault>view_catalog</RestrictionDefault> + <RestrictionNumber>1</RestrictionNumber> + </Restrictions> + <Restrictions> + <CollectionName>ViewColumns</CollectionName> + <RestrictionName>ViewSchema</RestrictionName> + <RestrictionDefault>view_schema</RestrictionDefault> + <RestrictionNumber>2</RestrictionNumber> + </Restrictions> + <Restrictions> + <CollectionName>ViewColumns</CollectionName> + <RestrictionName>ViewName</RestrictionName> + <RestrictionDefault>view_name</RestrictionDefault> + <RestrictionNumber>3</RestrictionNumber> + </Restrictions> + <Restrictions> + <CollectionName>ViewColumns</CollectionName> + <RestrictionName>ColumnName</RestrictionName> + <RestrictionDefault>column_name</RestrictionDefault> + <RestrictionNumber>4</RestrictionNumber> + </Restrictions> <DataSourceInformation> <CompositeIdentifierSeparatorPattern>.</CompositeIdentifierSeparatorPattern> <DataSourceProductName>PostgreSQL</DataSourceProductName> Modified: trunk/pgsqlclient/source/PostgreSql/Data/Schema/PgViewColumns.cs =================================================================== --- trunk/pgsqlclient/source/PostgreSql/Data/Schema/PgViewColumns.cs 2006-03-27 12:45:14 UTC (rev 56) +++ trunk/pgsqlclient/source/PostgreSql/Data/Schema/PgViewColumns.cs 2006-03-27 13:04:09 UTC (rev 57) @@ -25,7 +25,48 @@ protected override string BuildSql(string[] restrictions) { - throw new NotImplementedException(); + string sql = + "SELECT " + + "current_database() AS VIEW_CATALOG, " + + "pg_namespace.nspname AS VIEW_SCHEMA, " + + "pg_class.relname AS VIEW_NAME, " + + "pg_attribute.attname AS COLUMN_NAME " + + "FROM " + + "pg_class " + + "left join pg_namespace ON pg_class.relnamespace = pg_namespace.oid " + + "left join pg_attribute ON pg_attribute.attrelid = pg_class.oid " + + "WHERE " + + "pg_class.relkind = 'v' "; + + if (restrictions != null && restrictions.Length > 0) + { + // VIEW_CATALOG + if (restrictions.Length > 0 && restrictions[0] != null) + { + } + + // VIEW_SCHEMA + if (restrictions.Length > 1 && restrictions[1] != null) + { + sql += String.Format(" and pg_namespace.nspname = '{0}'", restrictions[1]); + } + + // VIEW_NAME + if (restrictions.Length > 2 && restrictions[2] != null) + { + sql += String.Format(" and pg_class.relname = '{0}'", restrictions[2]); + } + + // COLUMN_NAME + if (restrictions.Length > 3 && restrictions[3] != null) + { + sql += String.Format(" and pg_attribute.attname = '{0}'", restrictions[3]); + } + } + + sql += " ORDER BY pg_namespace.nspname, pg_class.relname"; + + return sql; } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |