Author: phd
Date: 2006-10-12 07:48:23 -0600 (Thu, 12 Oct 2006)
New Revision: 2017
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/firebird/firebirdconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/maxdb/maxdbconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/sybase/sybaseconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/dbtest.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto.py
Log:
Get column's dbName from the DB.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/firebird/firebirdconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/firebird/firebirdconnection.py 2006-10-12 13:47:59 UTC (rev 2016)
+++ SQLObject/branches/0.7-bugfix/sqlobject/firebird/firebirdconnection.py 2006-10-12 13:48:23 UTC (rev 2017)
@@ -191,6 +191,7 @@
continue
colClass, kw = self.guessClass(t, flength, fscale)
kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
+ kw['dbName'] = field
kw['notNone'] = not nullAllowed
kw['default'] = thedefault
results.append(colClass(**kw))
Modified: SQLObject/branches/0.7-bugfix/sqlobject/maxdb/maxdbconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/maxdb/maxdbconnection.py 2006-10-12 13:47:59 UTC (rev 2016)
+++ SQLObject/branches/0.7-bugfix/sqlobject/maxdb/maxdbconnection.py 2006-10-12 13:48:23 UTC (rev 2017)
@@ -7,7 +7,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-connection creation sample
+connection creation sample
__connection__ = DBConnection.maxdbConnection(
host=hostname, database=dbname,
user=user_name, password=user_password,autoCommit=1,debug=1)
@@ -25,7 +25,7 @@
def __str__(self):
return repr(self.value)
-
+
class LowerBoundOfSliceIsNotSupported(maxdbException):
def __init__(self, value):
maxdbException.__init__(self, '')
@@ -51,14 +51,14 @@
self,
"No primary key was defined on table %r" % value)
-SAPDBMAX_ID_LENGTH=32
+SAPDBMAX_ID_LENGTH=32
class MaxdbConnection(DBAPI):
-
+
supportTransactions = True
dbName = 'maxdb'
schemes = [dbName]
-
+
def __init__ (self, user, password, database,
host='', autoCommit=1, sqlmode='internal',
isolation=None, timeout=None, **kw):
@@ -101,7 +101,7 @@
conn.__init__(self.user, self.password, self.database,
self.host,
**self._getConfigParams(self.sqlmode,auto))
-
+
def createSequenceName(self,table):
"""
sequence name are builded with the concatenation of the table
@@ -150,16 +150,16 @@
limit = ' ROWNO <= %d ' % (end)
return self.sqlAddLimit(query,limit)
-
+
def createTable(self, soClass):
#we create the table in a transaction because the addition of the
- #table and the sequence must be atomic
+ #table and the sequence must be atomic
- #i tried to use the transaction class but i get a recursion limit error
+ #i tried to use the transaction class but i get a recursion limit error
#t=self.transaction()
# t.query('CREATE TABLE %s (\n%s\n)' % \
# (soClass.sqlmeta.table, self.createColumns(soClass)))
- #
+ #
# t.query("CREATE SEQUENCE %s" % self.createSequenceName(soClass.sqlmeta.table))
# t.commit()
#so use transaction when the problem will be solved
@@ -167,7 +167,7 @@
(soClass.sqlmeta.table, self.createColumns(soClass)))
self.query("CREATE SEQUENCE %s"
% self.createSequenceName(soClass.sqlmeta.table))
-
+
def createColumn(self, soClass, col):
return col.maxdbCreateSQL()
@@ -179,7 +179,7 @@
def dropTable(self, tableName,cascade=False):
#we drop the table in a transaction because the removal of the
- #table and the sequence must be atomic
+ #table and the sequence must be atomic
#i tried to use the transaction class but i get a recursion limit error
# try:
# t=self.transaction()
@@ -219,7 +219,7 @@
GET_PK_AND_FK = """
SELECT constraint_cols.column_name, constraints.constraint_type,
refname,reftablename
- FROM user_cons_columns constraint_cols
+ FROM user_cons_columns constraint_cols
INNER JOIN user_constraints constraints
ON constraint_cols.constraint_name = constraints.constraint_name
LEFT OUTER JOIN show_foreign_key fk
@@ -239,7 +239,7 @@
pkmap[col_name]=False
if cons_type == 'R':
keymap[col_name]=reftable.lower()
-
+
elif cons_type == 'P':
pkmap[col_name]=True
@@ -250,14 +250,15 @@
data_scale) in colData:
# id is defined as primary key --> ok
# We let sqlobject raise error if the 'id' is used for another column
- field_name = field.lower()
+ field_name = field.lower()
if field_name == 'id' and pkmap[field_name]:
continue
-
+
colClass, kw = self.guessClass(data_type,data_len,data_scale)
kw['name'] = field_name
+ kw['dbName'] = field
- if nullAllowed == 'Y' :
+ if nullAllowed == 'Y' :
nullAllowed=False
else:
nullAllowed=True
@@ -270,9 +271,9 @@
kw['foreignKey'] = keymap[field_name]
results.append(colClass(**kw))
-
+
return results
-
+
_numericTypes=['INTEGER', 'INT','SMALLINT']
_dateTypes=['DATE','TIME','TIMESTAMP']
Modified: SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py 2006-10-12 13:47:59 UTC (rev 2016)
+++ SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py 2006-10-12 13:48:23 UTC (rev 2017)
@@ -213,6 +213,7 @@
# precision is needed for decimal columns
colClass, kw = self.guessClass(t, size, precision, scale)
kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
+ kw['dbName'] = field
kw['notNone'] = not nullAllowed
if (defaultText):
# Strip ( and )
Modified: SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py 2006-10-12 13:47:59 UTC (rev 2016)
+++ SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py 2006-10-12 13:48:23 UTC (rev 2017)
@@ -157,6 +157,7 @@
if self.kw.get('use_unicode') and colClass is col.StringCol:
colClass = col.UnicodeCol
kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
+ kw['dbName'] = field
kw['notNone'] = not nullAllowed
if default and t.startswith('int'):
kw['default'] = int(default)
Modified: SQLObject/branches/0.7-bugfix/sqlobject/sybase/sybaseconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/sybase/sybaseconnection.py 2006-10-12 13:47:59 UTC (rev 2016)
+++ SQLObject/branches/0.7-bugfix/sqlobject/sybase/sybaseconnection.py 2006-10-12 13:48:23 UTC (rev 2017)
@@ -140,6 +140,7 @@
continue
colClass, kw = self.guessClass(t)
kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
+ kw['dbName'] = field
kw['notNone'] = not nullAllowed
kw['default'] = default
# @@ skip key...
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/dbtest.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/dbtest.py 2006-10-12 13:47:59 UTC (rev 2016)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/dbtest.py 2006-10-12 13:48:23 UTC (rev 2017)
@@ -35,7 +35,7 @@
'+restrictedEnum': 'postgres',
'-transactions': 'mysql',
'-dropTableCascade': 'sybase mssql',
- '-fromDatabase': 'sqlite sybase firebird',
+ '-fromDatabase': 'sqlite',
'-expressionIndex': 'mysql sqlite firebird mssql',
'-blobData': 'mssql',
'-decimalColumn': 'mssql',
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto.py 2006-10-12 13:47:59 UTC (rev 2016)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto.py 2006-10-12 13:48:23 UTC (rev 2017)
@@ -174,3 +174,7 @@
assert jane.longField == 'x'*1000
del classregistry.registry(
AutoTest.sqlmeta.registry).classes['AutoTest']
+
+ columns = AutoTest.sqlmeta.columns
+ assert columns["lastName"].dbName == "last_name"
+ assert columns["wannahavefun"].dbName == "wannahavefun"
|