[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue-designer/src/templates/schema Introspectio...
From: |
Jason Cater |
Subject: |
gnue-designer/src/templates/schema Introspectio... |
Date: |
Wed, 25 Jun 2003 19:10:15 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue-designer
Branch:
Changes by: Jason Cater <address@hidden> 03/06/25 19:10:15
Modified files:
src/templates/schema: Introspection.py
Log message:
added default value, precision, etc, support to the Introspection wizard
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-designer/src/templates/schema/Introspection.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
Patches:
Index: gnue-designer/src/templates/schema/Introspection.py
diff -c gnue-designer/src/templates/schema/Introspection.py:1.9
gnue-designer/src/templates/schema/Introspection.py:1.10
*** gnue-designer/src/templates/schema/Introspection.py:1.9 Wed May 28
18:19:32 2003
--- gnue-designer/src/templates/schema/Introspection.py Wed Jun 25 19:10:15 2003
***************
*** 135,140 ****
--- 135,141 ----
print "Adding <tables>"
tables = self.AddElement('tables', self.root, {})
+
# Create each table
for tablename in tablesorted:
print "Adding <table> %s" % tablename
***************
*** 142,147 ****
--- 143,153 ----
table = self.AddElement( 'table', tables,
{ 'name': tablename } )
+ try:
+ primarykeys = schema.primarykey
+ except:
+ primarykeys = []
+
fields = self.AddElement('fields', table, {})
# Add each field
***************
*** 152,158 ****
# Add length if appropriate for this datatype
try:
! attrs['length'] = int(field.length)
except AttributeError:
pass
--- 158,174 ----
# Add length if appropriate for this datatype
try:
! if field.datatype != 'date':
! attrs['length'] = int(field.length)
! except AttributeError:
! if field.datatype == 'number':
! attrs['length'] = 12
! elif field.datatype == 'text':
! attrs['length'] = 200
!
! # ... precision
! try:
! attrs['precision'] = int(field.precision)
except AttributeError:
pass
***************
*** 162,175 ****
except AttributeError:
attrs['nullable'] = 1
# Create the field element
self.AddElement('field', fields, attrs)
# Primary keys
! if hasattr(schema,'primarykey') and schema.primarykey:
pk = self.AddElement ('primarykey', table, {})
pk.name='pk_%s' % tablename
! for field in schema.primarykey:
self.AddElement('pkfield', pk, {'name': field})
# Add misc tags
--- 178,206 ----
except AttributeError:
attrs['nullable'] = 1
+ # ... default values?
+ if hasattr(field,'defaulttype'):
+ if field.defaulttype == 'serial':
+ attrs['defaultwith'] = 'serial'
+ if field.name in primarykeys and field.datatype == 'number':
+ attrs['type'] = 'key'
+ elif field.defaulttype == 'sequence':
+ attrs['defaultwith'] = 'sequence'
+ attrs['default'] = field.defaultval
+ elif field.defaulttype == 'constant':
+ attrs['defaultwith'] = 'constant'
+ attrs['default'] = field.defaultval
+
+
+
# Create the field element
self.AddElement('field', fields, attrs)
# Primary keys
! if primarykeys:
pk = self.AddElement ('primarykey', table, {})
pk.name='pk_%s' % tablename
! for field in primarykeys:
self.AddElement('pkfield', pk, {'name': field})
# Add misc tags
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue-designer/src/templates/schema Introspectio...,
Jason Cater <=