[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5941 - in trunk/gnue-common/src/datasources/drivers: Base DBSIG2/Schema
From: |
johannes |
Subject: |
r5941 - in trunk/gnue-common/src/datasources/drivers: Base DBSIG2/Schema/Creation interbase/Schema/Discovery interbase/interbase postgresql/Base postgresql/Schema/Discovery |
Date: |
Wed, 7 Jul 2004 17:14:20 -0500 (CDT) |
Author: johannes
Date: 2004-07-05 10:06:03 -0500 (Mon, 05 Jul 2004)
New Revision: 5941
Modified:
trunk/gnue-common/src/datasources/drivers/Base/Connection.py
trunk/gnue-common/src/datasources/drivers/DBSIG2/Schema/Creation/Creation.py
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Discovery/Introspection.py
trunk/gnue-common/src/datasources/drivers/interbase/interbase/Connection.py
trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
trunk/gnue-common/src/datasources/drivers/postgresql/Schema/Discovery/Introspection.py
Log:
Added an 'identifier' conversion to the connection, checking of duplicate
constraints now works as intended
Modified: trunk/gnue-common/src/datasources/drivers/Base/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/Connection.py
2004-07-05 09:54:57 UTC (rev 5940)
+++ trunk/gnue-common/src/datasources/drivers/Base/Connection.py
2004-07-05 15:06:03 UTC (rev 5941)
@@ -73,6 +73,27 @@
def connect(self, connectData):
pass
+
+ # ---------------------------------------------------------------------------
+ # Return an identifier usable by the connection
+ # ---------------------------------------------------------------------------
+
+ def identifier (self, identifier):
+ """
+ This function transforms an identifier to be safely used by the connection.
+ Descendants can override this function to do their stuff like switching
+ case and so on.
+
+ @param identifier: the identifier to be processed
+ @return: string with a safe identifier
+ """
+ return identifier
+
+
+ # ---------------------------------------------------------------------------
+ # update the schema definition
+ # ---------------------------------------------------------------------------
+
def updateSchema (self, definition, codeOnly = False):
"""
This function modifies the database schema according to the given
@@ -104,7 +125,7 @@
# occurence.
for table in workingSet:
# Do we have already a table with that name?
- res = self.introspector.find (name = table ['name'])
+ res = self.introspector.find (name = self.identifier (table ['name']))
if res is not None:
method = self.schemaCreator.modifyTable
@@ -113,7 +134,7 @@
# keep only new fields
keep = []
for field in table ['fields']:
- if not field ['name'] in existingFields:
+ if not self.identifier (field ['name']) in existingFields:
keep.append (field)
table ['fields'] = keep
@@ -127,7 +148,7 @@
keep = []
for index in table ['indices']:
for field in index ['fields']:
- if not field in existingFields:
+ if not self.identifier (field) in existingFields:
keep.append (index)
break
@@ -140,7 +161,7 @@
for constraint in table ['constraints']:
for field in constraint ['fields']:
- if not field in existingFields:
+ if not self.identifier (field) in existingFields:
keep.append (constraint)
break
Modified:
trunk/gnue-common/src/datasources/drivers/DBSIG2/Schema/Creation/Creation.py
===================================================================
---
trunk/gnue-common/src/datasources/drivers/DBSIG2/Schema/Creation/Creation.py
2004-07-05 09:54:57 UTC (rev 5940)
+++
trunk/gnue-common/src/datasources/drivers/DBSIG2/Schema/Creation/Creation.py
2004-07-05 15:06:03 UTC (rev 5941)
@@ -263,9 +263,11 @@
"""
res = Base.Creation.createConstraint (self, tableName, constraintDef,
codeOnly)
- cName = self._shortenName (constraintDef ['name'])
- if self.lookup.has_key ("CONSTRAINT_%s" % cName):
- return ([], [], [])
+ cName = self._shortenName (constraintDef ['name'])
+ tries = 0
+ while self.lookup.has_key ("CONSTRAINT_%s" % cName) and tries <= 10:
+ cName = "%s%d" % (cName [:-1], tries)
+ tries += 1
fields = constraintDef ['fields']
reftable = constraintDef ['reftable']
Modified:
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Discovery/Introspection.py
===================================================================
---
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Discovery/Introspection.py
2004-07-05 09:54:57 UTC (rev 5940)
+++
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Discovery/Introspection.py
2004-07-05 15:06:03 UTC (rev 5941)
@@ -155,7 +155,7 @@
nativetype='unknown'
attrs={'id':d[DESCRIPTION_NAME],
- 'name':lower(d[DESCRIPTION_NAME]),
+ 'name':lower (d[DESCRIPTION_NAME]),
'type':'field',
'nativetype': nativetype,
'required': d[DESCRIPTION_NULL_OK]==0,
Modified:
trunk/gnue-common/src/datasources/drivers/interbase/interbase/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/interbase/interbase/Connection.py
2004-07-05 09:54:57 UTC (rev 5940)
+++ trunk/gnue-common/src/datasources/drivers/interbase/interbase/Connection.py
2004-07-05 15:06:03 UTC (rev 5941)
@@ -169,8 +169,11 @@
return None
+ def identifier (self, identifier):
+ return identifier.lower ()
+
# RDB$CHARACTER_SETS.RDB$CHARACTER_SET_NAME
ib_encTable = {'ascii' : 'ASCII',
'' : 'BIG_5',
Modified:
trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
2004-07-05 09:54:57 UTC (rev 5940)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
2004-07-05 15:06:03 UTC (rev 5941)
@@ -123,6 +123,20 @@
def getSequence(self, name):
return self.sql1 ("select nextval('%s')" % name)
+ # ---------------------------------------------------------------------------
+ # PostgreSQL treats all identifiers as lowercase
+ # ---------------------------------------------------------------------------
+
+ def identifier (self, identifier):
+ """
+ This function converts an identifier to lowercase letters only
+
+ @param identifier: identifier to be converted
+ @return: lowercase string
+ """
+ return identifier.lower ()
+
+
pg_encTable = {'ascii' : 'SQL_ASCII', # ASCII
'' : 'EUC_JP', # Japanese EUC
'' : 'EUC_CN', # Chinese EUC
Modified:
trunk/gnue-common/src/datasources/drivers/postgresql/Schema/Discovery/Introspection.py
===================================================================
---
trunk/gnue-common/src/datasources/drivers/postgresql/Schema/Discovery/Introspection.py
2004-07-05 09:54:57 UTC (rev 5940)
+++
trunk/gnue-common/src/datasources/drivers/postgresql/Schema/Discovery/Introspection.py
2004-07-05 15:06:03 UTC (rev 5941)
@@ -52,7 +52,7 @@
if name is None:
return self.getSchemaList(type)
else:
- rs = self.getSchemaByName(name, type)
+ rs = self.getSchemaByName(self._connection.identifier (name), type)
if rs:
return [rs]
else:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5941 - in trunk/gnue-common/src/datasources/drivers: Base DBSIG2/Schema/Creation interbase/Schema/Discovery interbase/interbase postgresql/Base postgresql/Schema/Discovery,
johannes <=