From 4f7b93096bb0010db2337d9120eefaa59517bb36 Mon Sep 17 00:00:00 2001 From: rylek Date: Mon, 21 Mar 2011 22:04:39 +0000 Subject: [PATCH] *OleDB: fixed EnumPrimaryKey git-svn-id: svn://ultimatepp.org/upp/trunk@3295 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/OleDB/OleDB.cpp | 15 ++++++++++----- uppsrc/OleDB/OleDB.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/uppsrc/OleDB/OleDB.cpp b/uppsrc/OleDB/OleDB.cpp index 759e0a47e..03ac7df36 100644 --- a/uppsrc/OleDB/OleDB.cpp +++ b/uppsrc/OleDB/OleDB.cpp @@ -1381,7 +1381,7 @@ Vector OleDBSession::EnumSequences(String database) return out; } -Vector OleDBSession::EnumPrimaryKeys(String database, String table) +Vector OleDBSession::EnumPrimaryKey(String database, String table) { Vector out; IRef srowset; @@ -1389,10 +1389,15 @@ Vector OleDBSession::EnumPrimaryKeys(String database, String table) OleVariant restrictions[3]; restrictions[0].vt = VT_BSTR; restrictions[0].bstrVal = StringToBSTR(database); - restrictions[1].vt = VT_BSTR; - restrictions[1].bstrVal = StringToBSTR(database); - restrictions[2].vt = VT_BSTR; - restrictions[2].bstrVal = StringToBSTR(table); + Vector parts = Split(table, '.'); + if(parts.GetCount() > 1) { + restrictions[1].vt = VT_BSTR; + restrictions[1].bstrVal = StringToBSTR(parts[0]); + } + if(!parts.IsEmpty()) { + restrictions[2].vt = VT_BSTR; + restrictions[2].bstrVal = StringToBSTR(parts.Top()); + } IRef trowset; OleVerify(srowset->GetRowset(NULL, DBSCHEMA_PRIMARY_KEYS, __countof(restrictions), restrictions, trowset.GetIID(), 0, NULL, trowset.SetUnk())); diff --git a/uppsrc/OleDB/OleDB.h b/uppsrc/OleDB/OleDB.h index c269e10d8..4221ff086 100644 --- a/uppsrc/OleDB/OleDB.h +++ b/uppsrc/OleDB/OleDB.h @@ -51,7 +51,7 @@ public: virtual Vector EnumTables(String database); virtual Vector EnumViews(String database); virtual Vector EnumSequences(String database); - virtual Vector EnumPrimaryKeys(String database, String table); + virtual Vector EnumPrimaryKey(String database, String table); virtual String EnumRowID(String database, String table); struct Provider