[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fdo-commits
Subject:    [fdo-commits] r6761 - in trunk/Providers/GenericRdbms/Src: ODBC/SchemaMgr/Lp ODBC/SchemaMgr/Ph UnitT
From:       svn_fdo () osgeo ! org
Date:       2013-01-29 16:33:00
Message-ID: 20130129163301.56031390602 () trac ! osgeo ! org
[Download RAW message or body]

Author: brentrobinson
Date: 2013-01-29 08:33:00 -0800 (Tue, 29 Jan 2013)
New Revision: 6761

Modified:
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Lp/Schema.cpp
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Mgr.cpp
   trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp
   trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.cpp
   trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcDescribeSchemaTest.cpp
   trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp
Log:
Ticket#853: ODBC: handle SQL Server databases that have a schema called "Fdo".

Modified: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Lp/Schema.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Lp/Schema.cpp	2013-01-29 06:42:52 \
                UTC (rev 6760)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Lp/Schema.cpp	2013-01-29 16:33:00 \
UTC (rev 6761) @@ -20,6 +20,7 @@
 #include "stdafx.h"
 #include <FdoRdbmsUtil.h>
 #include "Schema.h"
+#include "../Ph/Mgr.h"
 #include <Sm/Lp/SchemaCollection.h>
 #include "DataPropertyDefinition.h"
 #include "GeometricPropertyDefinition.h"
@@ -71,12 +72,19 @@
     FdoFeatureSchemasP configSchemas = GetPhysicalSchema()->GetConfigSchemas();
     FdoSchemaMappingsP configMappings = GetPhysicalSchema()->GetConfigMappings();
 
+    rdbi_vndr_info_def info;
+	rdbi_vndr_info(GetPhysicalSchema()->SmartCast<FdoSmPhOdbcMgr>()->GetRdbiContext(), \
&info ); +    
     // The following is similar to what FdoSmPhOdbcMgr::::CreateRdClassReader() does
     // to map a logical schema to the owner containing its physical objects.
     // When no config document was passed to the connection, each non-default schema
     // maps to an owner of the same name. Each owner maps to a physical schema.
+	//
+	// For SQLServer sources the "Fdo" schema is not treated specially since it can be \
the  +	// name of a physical schema in the SQL Server database.
     if ( (configSchemas == NULL) && (configMappings == NULL ) &&
-         (schemaName.GetLength() > 0) && (schemaName != \
GetPhysicalSchema()->RdSchemaPrefix) ) +         (schemaName.GetLength() > 0) && 
+		 (info.dbversion == RDBI_DBVERSION_ODBC_SQLSERVER || schemaName != \
GetPhysicalSchema()->RdSchemaPrefix) )  {
         owner = GetPhysicalSchema()->GetOwner(schemaName);
     }

Modified: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Mgr.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Mgr.cpp	2013-01-29 06:42:52 \
                UTC (rev 6760)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Mgr.cpp	2013-01-29 16:33:00 \
UTC (rev 6761) @@ -87,13 +87,19 @@
     FdoStringP owner
 )
 {
+    rdbi_vndr_info_def info;
+	rdbi_vndr_info(GetRdbiContext(), &info );
+    
 #pragma message ("TODO: look up schema object to get owner name")
     // Ideally, we would not exclude based on RdSchemaPrefix, but rather
     // look up an approprate owner name, based on schemaName, or adjust the calling
     // code to pass in the right owner name -- which may be an empty string
     // on data sources that do not support named physical schemas.
+	//
+	// For SQL Server sources, there could be a physical schema called "Fdo" so don't
+	// treat it specially, use it as the owner name.
     if (schemaName != NULL && schemaName.GetLength() > 0 &&
-        schemaName != this->RdSchemaPrefix &&
+        (info.dbversion == RDBI_DBVERSION_ODBC_SQLSERVER || schemaName != \
this->RdSchemaPrefix) &&  (owner == NULL || owner.GetLength() <= 0) )
     {
         owner = schemaName;

Modified: trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp	2013-01-29 \
                06:42:52 UTC (rev 6760)
+++ trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp	2013-01-29 \
16:33:00 UTC (rev 6761) @@ -345,7 +345,9 @@
 	L"z decimal(16,6)  NULL",
 	L");",
     L"",
-	L"create table guest.cities (",
+    L"create schema Fdo;",
+    L"",
+	L"create table Fdo.cities (",
 	L"cityid int NOT NULL,",
 	L"name varchar(50) NULL,",
 	L"x float NOT NULL,",
@@ -353,21 +355,21 @@
     L"primary key (cityid)",
 	L");",
     L"",
-	L"insert into guest.cities ",
+	L"insert into Fdo.cities ",
 	L"( cityid, name, x, y )",
 	L" values ",
 	L"( 1, 'Cedarville', 25, 85 );",
     L"",
-	L"insert into guest.cities ",
+	L"insert into Fdo.cities ",
 	L"( cityid, name, x, y )",
 	L" values ",
 	L"( 2, 'Lakeview', 48, 23 );",
-	L"insert into guest.cities ",
+	L"insert into Fdo.cities ",
 	L"( cityid, name, x, y )",
 	L" values ",
 	L"( 3, 'Sandborough', 10, 39 );",
     L"",
-	L"create table guest.table3 (",
+	L"create table Fdo.table3 (",
 	L"featid1 int NOT NULL,",
 	L"name varchar(50) NULL,",
     L"amount int NOT NULL,"
@@ -376,7 +378,7 @@
     L"primary key (featid1)"
 	L");",
     L"",
-	L"insert into guest.table3 ",
+	L"insert into Fdo.table3 ",
 	L"( featid1, name, amount, x, y )",
 	L" values ",
 	L"( 1, 'GuestName', 5005, 10.25, 15.125 );",

Modified: trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.cpp	2013-01-29 \
                06:42:52 UTC (rev 6760)
+++ trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.cpp	2013-01-29 \
16:33:00 UTC (rev 6761) @@ -1003,6 +1003,7 @@
     sprintf (teststr, "DSN=%s%cDescription=Test MySql DSN for FDO ODBC \
provider%cSERVER=%s%cDATABASE=%ls%cOPTION=3%c%c", (const \
char*)(FdoStringP)m_SetupValues->GetPropertyValue( L"DSNMySql" ),   '\0','\0', (const \
char*)(FdoStringP)m_SetupValues->GetPropertyValue( L"serviceMySql" ), '\0', \
(FdoString*)(UnitTestUtil::GetEnviron("datastore", L"")), '\0', '\0', '\0');  \
m_SetupMySqlDSNdone = true; +#if 0
     if (!SQLConfigDataSource (NULL, ODBC_ADD_DSN, (const \
char*)MYSQL_ODBC_DRIVER_NAME, teststr))  {
         DWORD error;
@@ -1011,6 +1012,7 @@
         printf (teststr);
         throw FdoException::Create (L"MySql DSN setup failed");
     }
+#endif
 }
 
 void OdbcConnectionUtil::TeardownAccessDSN()
@@ -1087,6 +1089,7 @@
 
 void OdbcConnectionUtil::TeardownMySqlDSN()
 {
+#if 0
     char pString[SQL_MAX_MESSAGE_LENGTH];
     DWORD error;
     WORD count;
@@ -1097,6 +1100,7 @@
         printf ("\nMySql DSN teardown failed:\n");
         printf (pString);
     }
+#endif
 }
 
 void OdbcConnectionUtil::TeardownOracleDSN()

Modified: trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcDescribeSchemaTest.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcDescribeSchemaTest.cpp	2013-01-29 \
                06:42:52 UTC (rev 6760)
+++ trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcDescribeSchemaTest.cpp	2013-01-29 \
16:33:00 UTC (rev 6761) @@ -175,8 +175,8 @@
         CPPUNIT_ASSERT(classNames->GetItem(4)->GetString() == L"dbo:table7");
         CPPUNIT_ASSERT(classNames->GetItem(5)->GetString() == L"dbo:table8");
         CPPUNIT_ASSERT(classNames->GetItem(6)->GetString() == L"dbo:view1");
-        CPPUNIT_ASSERT(classNames->GetItem(7)->GetString() == L"guest:cities");
-        CPPUNIT_ASSERT(classNames->GetItem(8)->GetString() == L"guest:table3");
+        CPPUNIT_ASSERT(classNames->GetItem(7)->GetString() == L"Fdo:cities");
+        CPPUNIT_ASSERT(classNames->GetItem(8)->GetString() == L"Fdo:table3");
     }
     catch (FdoException *ex)
     {

Modified: trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp	2013-01-29 \
                06:42:52 UTC (rev 6760)
+++ trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp	2013-01-29 \
16:33:00 UTC (rev 6761) @@ -376,7 +376,7 @@
 
             FdoPtr<FdoISelect> selectCmd = \
(FdoISelect*)mConnection->CreateCommand(FdoCommandType_Select);  
-            selectCmd->SetFeatureClassName(L"guest:table3");
+            selectCmd->SetFeatureClassName(L"Fdo:table3");
 
             FdoPtr<FdoIFeatureReader> reader = selectCmd->Execute();
 
@@ -403,7 +403,7 @@
             // close the reader
             reader->Close();
 
-            selectCmd->SetFeatureClassName(L"guest:cities");
+            selectCmd->SetFeatureClassName(L"Fdo:cities");
 
             reader = selectCmd->Execute();
 
@@ -439,7 +439,7 @@
                     break;
 
                 default:
-                    CPPUNIT_FAIL("Unexpected value for guest.cities.cityid");
+                    CPPUNIT_FAIL("Unexpected value for Fdo.cities.cityid");
                     break;
                 }
                 numFeatures++;

_______________________________________________
fdo-commits mailing list
fdo-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fdo-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic