[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src/schema GSParser.py scripter/Scr...
From: |
Derek Neighbors |
Subject: |
gnue/common/src/schema GSParser.py scripter/Scr... |
Date: |
Fri, 06 Dec 2002 12:28:18 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Branch: common-0-4-1-branch
Changes by: Derek Neighbors <address@hidden> 02/12/06 12:28:18
Modified files:
common/src/schema: GSParser.py
common/src/schema/scripter: Scripter.py
common/src/schema/scripter/processors: __init__.py base.py
oracle.py postgresql.py
Log message:
Upgrades to schema tool for oracle and primary key support.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/schema/GSParser.py.diff?cvsroot=OldCVS&only_with_tag=common-0-4-1-branch&tr1=1.13&tr2=1.13.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/schema/scripter/Scripter.py.diff?cvsroot=OldCVS&only_with_tag=common-0-4-1-branch&tr1=1.1&tr2=1.1.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/schema/scripter/processors/__init__.py.diff?cvsroot=OldCVS&only_with_tag=common-0-4-1-branch&tr1=1.1&tr2=1.1.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/schema/scripter/processors/base.py.diff?cvsroot=OldCVS&only_with_tag=common-0-4-1-branch&tr1=1.1&tr2=1.1.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/schema/scripter/processors/oracle.py.diff?cvsroot=OldCVS&only_with_tag=common-0-4-1-branch&tr1=1.1&tr2=1.1.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/schema/scripter/processors/postgresql.py.diff?cvsroot=OldCVS&only_with_tag=common-0-4-1-branch&tr1=1.1&tr2=1.1.2.1&r1=text&r2=text
Patches:
Index: gnue/common/src/schema/GSParser.py
diff -c gnue/common/src/schema/GSParser.py:1.13
gnue/common/src/schema/GSParser.py:1.14
*** gnue/common/src/schema/GSParser.py:1.13 Tue Nov 12 20:43:43 2002
--- gnue/common/src/schema/GSParser.py Fri Dec 6 01:25:17 2002
***************
*** 205,210 ****
--- 205,211 ----
'Required': 1,
'Typecast': GTypecast.name },
'unique': {
+ 'Default': 0,
'Typecast': GTypecast.boolean } },
'ParentTags': ('indexes',) },
Index: gnue/common/src/schema/scripter/Scripter.py
diff -c gnue/common/src/schema/scripter/Scripter.py:1.2
gnue/common/src/schema/scripter/Scripter.py:1.3
*** gnue/common/src/schema/scripter/Scripter.py:1.2 Fri Dec 6 01:25:17 2002
--- gnue/common/src/schema/scripter/Scripter.py Fri Dec 6 01:46:58 2002
***************
*** 117,123 ****
else:
vens = vendor.split(',')
! if len(vens) > 1 and not os.path.isdir(output ):
self.handleStartupError('--output cannot reference a file '
'if multiple vendors are specified.')
--- 117,123 ----
else:
vens = vendor.split(',')
! if len(vens) > 1 and (output and not os.path.isdir(output)):
self.handleStartupError('--output cannot reference a file '
'if multiple vendors are specified.')
***************
*** 136,142 ****
if not output:
outfile = self.getVendorName(ven) + '.sql'
elif os.path.isdir(output):
! outfile = os.path.join(self.getVendorName(ven) + '.sql')
else:
outfile = output
--- 136,142 ----
if not output:
outfile = self.getVendorName(ven) + '.sql'
elif os.path.isdir(output):
! outfile = os.path.join(output, self.getVendorName(ven) + '.sql')
else:
outfile = output
Index: gnue/common/src/schema/scripter/processors/__init__.py
diff -c gnue/common/src/schema/scripter/processors/__init__.py:1.1
gnue/common/src/schema/scripter/processors/__init__.py:1.2
*** gnue/common/src/schema/scripter/processors/__init__.py:1.1 Sun Nov 10
17:06:34 2002
--- gnue/common/src/schema/scripter/processors/__init__.py Fri Dec 6
01:25:17 2002
***************
*** 0 ****
--- 1 ----
+ vendors = ['postgresql','oracle']
\ No newline at end of file
Index: gnue/common/src/schema/scripter/processors/base.py
diff -c gnue/common/src/schema/scripter/processors/base.py:1.1
gnue/common/src/schema/scripter/processors/base.py:1.2
*** gnue/common/src/schema/scripter/processors/base.py:1.1 Sun Nov 10
17:06:34 2002
--- gnue/common/src/schema/scripter/processors/base.py Fri Dec 6 01:25:17 2002
***************
*** 38,43 ****
--- 38,49 ----
COMMENT_END = ""
COMMENT_SINGLELINE=1
+ def __init__(self):
+ self.prepare()
+
+ def prepare(self):
+ pass
+
def number(self, attributes={}):
raise "Unsupported datatype: number"
***************
*** 87,98 ****
rv += "CREATE TABLE %s\n (" % name
rv += string.join(fields,',\n ') + ');\n'
if posttable:
! rv += string.join(posttable,';\n') + ';\n'
return rv
def createField(self, name, tablename, datatype, object):
rv = '%s %s' % (name, datatype)
! return rv
--- 93,117 ----
rv += "CREATE TABLE %s\n (" % name
rv += string.join(fields,',\n ') + ');\n'
if posttable:
! rv += "\n" + string.join(posttable,'\n') + '\n'
return rv
def createField(self, name, tablename, datatype, object):
rv = '%s %s' % (name, datatype)
! return ([rv], None, None, None)
!
!
! def createPrimaryKey(self, name, tablename, fields):
! rv = 'PRIMARY KEY (%s)' % string.join(fields,', ')
! return (None, [rv], None, None)
!
!
! def createIndex(self, name, tablename, fields, unique):
! rv = 'CREATE %sINDEX %s ON %s (%s);' % (unique and "UNIQUE " or "",
! name, tablename, string.join(fields,', '))
! return (None, None, None, [rv])
!
!
Index: gnue/common/src/schema/scripter/processors/oracle.py
diff -c gnue/common/src/schema/scripter/processors/oracle.py:1.1
gnue/common/src/schema/scripter/processors/oracle.py:1.2
*** gnue/common/src/schema/scripter/processors/oracle.py:1.1 Sun Nov 10
17:06:34 2002
--- gnue/common/src/schema/scripter/processors/oracle.py Fri Dec 6
01:25:17 2002
***************
*** 1,4 ****
name = "Oracle"
! description = "Oracle 7.x/8i/9i+"
--- 1,108 ----
name = "Oracle"
! description = "Oracle (7.x/8i/9i+)"
!
! from base import BaseProcessor
! import string
!
! _PK_PRECISION = 10
!
! class Processor(BaseProcessor):
!
!
! COMMENT_BEGIN = "REM ** "
! MAX_NAME_LENGTH = 31
!
! def prepare(self):
! self.trigWhen = []
! self.trigBody = []
!
!
! def number(self, object):
! if object.precision == 0:
! return "number(%s)" % object.length
! else:
! return "number(%s,%s)" % (object.length + object.precision,
object.precision)
!
! def string(self, object):
! return "varchar2(%s)" % object.length
!
! def date(self, object):
! return "date"
!
! def time(self, object):
! return "date"
!
! def timestamp(self, object):
! return "date"
!
! def text(self, object):
! return "long"
!
! def key(self, object):
! return "number(%s)" % _PK_PRECISION
!
!
! def createField(self, name, tablename, datatype, object):
! rv = '%s %s' % (name, datatype)
!
! posttable = []
! pretable = []
! trigWhen = self.trigWhen
! trigBody = self.trigBody
!
! if object.defaultwith == "serial":
!
! sq = tablename + '_' + name + '_seq'
! if len(sq) > self.MAX_NAME_LENGTH:
! sq = tablename + "_seq_"
! sq += str(object._parent._children.index(object))
! if len(sq) > self.MAX_NAME_LENGTH:
! sq = tablename + "_" + str(id(object)) + '_seq'
! if len(sq) > self.MAX_NAME_LENGTH:
! sq = 'seq_' + id(self)
!
! trigWhen.append('(new.%s is null)' % object.name)
! trigBody.append(' IF :new.%s IS NULL THEN\n' % (object.name) + \
! ' SELECT %s.nextval INTO :new.%s FROM dual;\n' %
(sq, object.name) + \
! ' END IF;')
!
! pretable.append ('CREATE SEQUENCE %s MAXVALUE %s NOCYCLE' % (sq,
'9'*_PK_PRECISION))
!
! elif object.defaultwith == "timestamp":
! sysdate = object.type == 'date' and "TRUNC(sysdate)" or "sysdate"
! trigWhen.append('(new.%s is null)' % object.name)
! trigBody.append(' IF :new.%s IS NULL then\n' % (object.name) + \
! ' :new.%s := %s;\n' % (object.name, sysdate) + \
! ' END IF;')
!
! elif hasattr(self,'default') and len(self.default):
! rv += ' DEFAULT %s' % self.default
!
! if not object.nullable:
! rv += ' NOT NULL'
!
! # Field def, Post-Field Def, Pre-Table command, Post-Table command
! return (rv,None,pretable or None,posttable or None)
!
! def createTable(self, name, fields, pretable=[], posttable=[]):
! trigWhen = self.trigWhen
! trigBody = self.trigBody
! if len(trigBody):
! if len(trigWhen):
! when = " WHEN ( %s )\n" % (string.join(trigWhen,' OR\n '))
! else:
! when = ""
!
! posttable.append ('CREATE OR REPLACE TRIGGER t__%s__pre\n' % name + \
! ' BEFORE INSERT ON %s\n' % name + \
! ' FOR EACH ROW\n' + \
! when + \
! ' BEGIN\n' + \
! string.join(trigBody,'\n') + '\n' +\
! ' END;\n/\n')
!
! self.prepare()
!
! return BaseProcessor.createTable(self, name, fields, pretable, posttable)
Index: gnue/common/src/schema/scripter/processors/postgresql.py
diff -c gnue/common/src/schema/scripter/processors/postgresql.py:1.1
gnue/common/src/schema/scripter/processors/postgresql.py:1.2
*** gnue/common/src/schema/scripter/processors/postgresql.py:1.1 Sun Nov
10 17:06:34 2002
--- gnue/common/src/schema/scripter/processors/postgresql.py Fri Dec 6
01:25:17 2002
***************
*** 31,37 ****
from base import BaseProcessor
name = "PostgreSQL"
! description = "Oracle 7.x/8i/9i+"
class Processor(BaseProcessor):
--- 31,37 ----
from base import BaseProcessor
name = "PostgreSQL"
! description = "PostgreSQL (6.x/7.x)"
class Processor(BaseProcessor):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/common/src/schema GSParser.py scripter/Scr...,
Derek Neighbors <=