Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer
In directory sc8-pr-cvs1:/tmp/cvs-serv17746/DatabaseAdaptors/MySQLAdaptorLayer
Modified Files:
MySQLSQLExpression.py
Log Message:
'TEXT' field now accepts a width to be set (ignored when generating the
database schema, but checked, if set, when validating an attribute's value)
Index: MySQLSQLExpression.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MySQLSQLExpression.py 8 Mar 2003 16:21:01 -0000 1.4
--- MySQLSQLExpression.py 31 May 2003 15:12:24 -0000 1.5
***************
*** 44,51 ****
available SQL data types.
"""
def valueTypeForExternalTypeMapping(self):
"""
REMOVES 'timestamp' from the available SQL types returned by
! Modeling.SQLExpression, and adds 'datetime'.
The reason for the removal of 'timestamp' is that, in MySQL, a DateTime
--- 44,86 ----
available SQL data types.
"""
+ def columnTypeStringForAttribute(self, attribute):
+ """
+ Overrides default implementation to handle TEXT field properly.
+
+ It returns a different string depending on some of the attribute's
+ properties:
+
+ - if attribute's precision is not zero: 'externalType(precision, scale)'
+
+ - if attribute's width is not zero and its externalType is not TEXT:
+ 'externalType(width)'
+
+ - otherwise returns: 'externalType'
+
+ About 'TEXT': a model can define a width for a TEXT field. It should be
+ ignored when generating the database schema (for example, TEXT(30) is an
+ invalid data type), however it might be set to request the validation
+ mechanism to check the attribute's length at runtime, typically before an
+ EditingContext saves its changes.
+
+ See also:
+ addCreateClauseForAttribute()
+ SchemaGeneration.createTableStatementsForEntityGroup()
+
+ """
+ if attribute.precision():
+ return attribute.externalType()+'('+\
+ str(attribute.precision())+','+str(attribute.scale())+')'
+ if attribute.width() and attribute:
+ if string.lower(attribute.externalType())!='text':
+ return attribute.externalType()+'('+\
+ str(attribute.width())+')'
+
+ return attribute.externalType()
+
def valueTypeForExternalTypeMapping(self):
"""
REMOVES 'timestamp' from the available SQL types returned by
! Modeling.SQLExpression, and adds 'datetime' and 'text'.
The reason for the removal of 'timestamp' is that, in MySQL, a DateTime
|