[Sqlalchemy-commits] [1241] sqlalchemy/trunk/test: merged Rick Morrison / Runar Petursson's MS-SQL m
Brought to you by:
zzzeek
From: <co...@sq...> - 2006-04-03 01:36:05
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:':';} #msg dl, #msg dt, #msg ul, #msg li { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[1241] sqlalchemy/trunk/test: merged Rick Morrison / Runar Petursson's MS-SQL module, with adjustments to alias schema-qualified Table objects</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1241</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2006-04-02 20:35:48 -0500 (Sun, 02 Apr 2006)</dd> </dl> <h3>Log Message</h3> <pre>merged Rick Morrison / Runar Petursson's MS-SQL module, with adjustments to alias schema-qualified Table objects</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunklibsqlalchemydatabases__init__py">sqlalchemy/trunk/lib/sqlalchemy/databases/__init__.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasesinformation_schemapy">sqlalchemy/trunk/lib/sqlalchemy/databases/information_schema.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemyenginepy">sqlalchemy/trunk/lib/sqlalchemy/engine.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemyschemapy">sqlalchemy/trunk/lib/sqlalchemy/schema.py</a></li> <li><a href="#sqlalchemytrunktestindexespy">sqlalchemy/trunk/test/indexes.py</a></li> <li><a href="#sqlalchemytrunktestselectpy">sqlalchemy/trunk/test/select.py</a></li> <li><a href="#sqlalchemytrunktesttestbasepy">sqlalchemy/trunk/test/testbase.py</a></li> <li><a href="#sqlalchemytrunktesttesttypespy">sqlalchemy/trunk/test/testtypes.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunklibsqlalchemydatabases__init__py"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/__init__.py (1240 => 1241)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/__init__.py 2006-04-02 22:56:19 UTC (rev 1240) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/__init__.py 2006-04-03 01:35:48 UTC (rev 1241) </span><span class="lines">@@ -5,4 +5,4 @@ </span><span class="cx"> # the MIT License: http://www.opensource.org/licenses/mit-license.php </span><span class="cx"> </span><span class="cx"> </span><del>-__all__ = ['oracle', 'postgres', 'sqlite', 'mysql'] </del><span class="cx">\ No newline at end of file </span><ins>+__all__ = ['oracle', 'postgres', 'sqlite', 'mysql', 'mssql'] </ins></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasesinformation_schemapy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/information_schema.py (1240 => 1241)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/information_schema.py 2006-04-02 22:56:19 UTC (rev 1240) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/information_schema.py 2006-04-03 01:35:48 UTC (rev 1241) </span><span class="lines">@@ -56,6 +56,18 @@ </span><span class="cx"> Column("constraint_name", String), </span><span class="cx"> schema="information_schema") </span><span class="cx"> </span><ins>+gen_ref_constraints = schema.Table("referential_constraints", generic_engine, + Column("constraint_catalog", String), + Column("constraint_schema", String), + Column("constraint_name", String), + Column("unique_constraint_catlog", String), + Column("unique_constraint_schema", String), + Column("unique_constraint_name", String), + Column("match_option", String), + Column("update_rule", String), + Column("delete_rule", String), + schema="information_schema") + </ins><span class="cx"> class ISchema(object): </span><span class="cx"> def __init__(self, engine): </span><span class="cx"> self.engine = engine </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemyenginepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/engine.py (1240 => 1241)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/engine.py 2006-04-02 22:56:19 UTC (rev 1240) +++ sqlalchemy/trunk/lib/sqlalchemy/engine.py 2006-04-03 01:35:48 UTC (rev 1241) </span><span class="lines">@@ -193,7 +193,7 @@ </span><span class="cx"> connection = property(_connection, doc="the connection represented by this SQLSession. The connection is late-connecting, meaning the call to the connection pool only occurs when it is first called (and the pool will typically only connect the first time it is called as well)") </span><span class="cx"> </span><span class="cx"> def begin(self): </span><del>- """begins" a transaction on this SQLSession's connection. repeated calls to begin() will increment a counter that must be decreased by corresponding commit() statements before an actual commit occurs. this is to provide "nested" behavior of transactions so that different functions in a particular call stack can call begin()/commit() independently of each other without knowledge of an existing transaction.""" </del><ins>+ """begins a transaction on this SQLSession's connection. repeated calls to begin() will increment a counter that must be decreased by corresponding commit() statements before an actual commit occurs. this is to provide "nested" behavior of transactions so that different functions in a particular call stack can call begin()/commit() independently of each other without knowledge of an existing transaction. """ </ins><span class="cx"> if self.__tcount == 0: </span><span class="cx"> self.__transaction = self.connection </span><span class="cx"> self.engine.do_begin(self.connection) </span><span class="lines">@@ -506,7 +506,7 @@ </span><span class="cx"> self.commit() </span><span class="cx"> </span><span class="cx"> def begin(self): </span><del>- """"begins a transaction on the current thread's SQLSession.""" </del><ins>+ """ begins a transaction on the current thread SQLSession. """ </ins><span class="cx"> self.session.begin() </span><span class="cx"> </span><span class="cx"> def rollback(self): </span><span class="lines">@@ -647,7 +647,7 @@ </span><span class="cx"> return ResultProxy(cursor, self, typemap=compiled.typemap) </span><span class="cx"> </span><span class="cx"> def execute(self, statement, parameters=None, connection=None, cursor=None, echo=None, typemap=None, commit=False, return_raw=False, **kwargs): </span><del>- """executes the given string-based SQL statement with the given parameters. </del><ins>+ """ executes the given string-based SQL statement with the given parameters. </ins><span class="cx"> </span><span class="cx"> The parameters can be a dictionary or a list, or a list of dictionaries or lists, depending </span><span class="cx"> on the paramstyle of the DBAPI. </span><span class="lines">@@ -659,7 +659,7 @@ </span><span class="cx"> up. </span><span class="cx"> </span><span class="cx"> In all error cases, a rollback() is immediately performed on the connection before </span><del>- propigating the exception outwards. </del><ins>+ propagating the exception outwards. </ins><span class="cx"> </span><span class="cx"> Other options include: </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemyschemapy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/schema.py (1240 => 1241)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/schema.py 2006-04-02 22:56:19 UTC (rev 1240) +++ sqlalchemy/trunk/lib/sqlalchemy/schema.py 2006-04-03 01:35:48 UTC (rev 1241) </span><span class="lines">@@ -256,7 +256,7 @@ </span><span class="cx"> default=None : a scalar, python callable, or ClauseElement representing the "default value" for this column, </span><span class="cx"> which will be invoked upon insert if this column is not present in the insert list or is given a value </span><span class="cx"> of None. </span><del>- </del><ins>+ </ins><span class="cx"> hidden=False : indicates this column should not be listed in the </span><span class="cx"> table's list of columns. Used for the "oid" column, which generally </span><span class="cx"> isnt in column lists. </span><span class="lines">@@ -271,7 +271,9 @@ </span><span class="cx"> indexed in a unique index . Pass true to autogenerate the index </span><span class="cx"> name. Pass a string to specify the index name. Multiple columns that </span><span class="cx"> specify the same index name will all be included in the index, in the </span><del>- order of their creation. """ </del><ins>+ order of their creation. + + """ </ins><span class="cx"> </span><span class="cx"> name = str(name) # in case of incoming unicode </span><span class="cx"> super(Column, self).__init__(name, None, type) </span><span class="lines">@@ -507,6 +509,7 @@ </span><span class="cx"> """calls the visit_seauence method on the given visitor.""" </span><span class="cx"> return visitor.visit_sequence(self) </span><span class="cx"> </span><ins>+ </ins><span class="cx"> class Index(SchemaItem): </span><span class="cx"> """Represents an index of columns from a database table </span><span class="cx"> """ </span></span></pre></div> <a id="sqlalchemytrunktestindexespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/indexes.py (1240 => 1241)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/indexes.py 2006-04-02 22:56:19 UTC (rev 1240) +++ sqlalchemy/trunk/test/indexes.py 2006-04-03 01:35:48 UTC (rev 1241) </span><span class="lines">@@ -42,9 +42,10 @@ </span><span class="cx"> """test that mixed-case index identifiers are legal""" </span><span class="cx"> employees = Table('companyEmployees', testbase.db, </span><span class="cx"> Column('id', Integer, primary_key=True), </span><del>- Column('firstName', String), - Column('lastName', String), - Column('emailAddress', String)) </del><ins>+ Column('firstName', String(30)), + Column('lastName', String(30)), + Column('emailAddress', String(30))) + </ins><span class="cx"> employees.create() </span><span class="cx"> self.created.append(employees) </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunktestselectpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/select.py (1240 => 1241)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/select.py 2006-04-02 22:56:19 UTC (rev 1240) +++ sqlalchemy/trunk/test/select.py 2006-04-03 01:35:48 UTC (rev 1241) </span><span class="lines">@@ -6,6 +6,7 @@ </span><span class="cx"> import sqlalchemy.databases.sqlite as sqlite </span><span class="cx"> </span><span class="cx"> db = ansisql.engine() </span><ins>+#db = create_engine('mssql') </ins><span class="cx"> </span><span class="cx"> from testbase import PersistTest </span><span class="cx"> import unittest, re </span><span class="lines">@@ -595,6 +596,7 @@ </span><span class="cx"> </span><span class="cx"> class SchemaTest(SQLTest): </span><span class="cx"> def testselect(self): </span><ins>+ # these tests will fail with the MS-SQL compiler since it will alias schema-qualified tables </ins><span class="cx"> self.runtest(table4.select(), "SELECT remotetable.rem_id, remotetable.datatype_id, remotetable.value FROM remote_owner.remotetable") </span><span class="cx"> self.runtest(table4.select(and_(table4.c.datatype_id==7, table4.c.value=='hi')), "SELECT remotetable.rem_id, remotetable.datatype_id, remotetable.value FROM remote_owner.remotetable WHERE remotetable.datatype_id = :remotetable_datatype_id AND remotetable.value = :remotetable_value") </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunktesttestbasepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/testbase.py (1240 => 1241)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/testbase.py 2006-04-02 22:56:19 UTC (rev 1240) +++ sqlalchemy/trunk/test/testbase.py 2006-04-03 01:35:48 UTC (rev 1241) </span><span class="lines">@@ -46,9 +46,11 @@ </span><span class="cx"> elif DBTYPE == 'oracle8': </span><span class="cx"> db_uri = 'oracle://user=scott&password=tiger' </span><span class="cx"> opts = {'use_ansi':False} </span><ins>+ elif DBTYPE == 'mssql': + db_uri = 'mssql://database=test&user=scott&password=tiger' </ins><span class="cx"> </span><span class="cx"> if not db_uri: </span><del>- raise "Could not create engine. specify --db <sqlite|sqlite_file|postgres|mysql|oracle> to test runner." </del><ins>+ raise "Could not create engine. specify --db <sqlite|sqlite_file|postgres|mysql|oracle|oracle8|mssql> to test runner." </ins><span class="cx"> </span><span class="cx"> if PROXY: </span><span class="cx"> db = proxy.ProxyEngine(echo=echo, default_ordering=True, **opts) </span></span></pre></div> <a id="sqlalchemytrunktesttesttypespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/testtypes.py (1240 => 1241)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/testtypes.py 2006-04-02 22:56:19 UTC (rev 1240) +++ sqlalchemy/trunk/test/testtypes.py 2006-04-03 01:35:48 UTC (rev 1241) </span><span class="lines">@@ -147,8 +147,8 @@ </span><span class="cx"> def testbinary(self): </span><span class="cx"> stream1 =self.get_module_stream('sqlalchemy.sql') </span><span class="cx"> stream2 =self.get_module_stream('sqlalchemy.engine') </span><del>- binary_table.insert().execute(misc='sql.pyc', data=stream1, data_slice=stream1[0:100]) - binary_table.insert().execute(misc='engine.pyc', data=stream2, data_slice=stream2[0:99]) </del><ins>+ binary_table.insert().execute(primary_id=1, misc='sql.pyc', data=stream1, data_slice=stream1[0:100]) + binary_table.insert().execute(primary_id=2, misc='engine.pyc', data=stream2, data_slice=stream2[0:99]) </ins><span class="cx"> l = binary_table.select().execute().fetchall() </span><span class="cx"> print len(stream1), len(l[0]['data']), len(l[0]['data_slice']) </span><span class="cx"> self.assert_(list(stream1) == list(l[0]['data'])) </span><span class="lines">@@ -179,7 +179,7 @@ </span><span class="cx"> collist = [Column('user_id', INT, primary_key = True), Column('user_name', VARCHAR(20)), Column('user_datetime', DateTime), </span><span class="cx"> Column('user_date', Date), Column('user_time', Time)] </span><span class="cx"> </span><del>- if db.engine.__module__.endswith('mysql'): </del><ins>+ if db.engine.__module__.endswith('mysql') or db.engine.__module__.endswith('mssql'): </ins><span class="cx"> # strip microseconds -- not supported by this engine (should be an easier way to detect this) </span><span class="cx"> for d in insert_data: </span><span class="cx"> if d[2] is not None: </span><span class="lines">@@ -198,6 +198,7 @@ </span><span class="cx"> users_with_date = Table('query_users_with_date', db, redefine = True, *collist) </span><span class="cx"> users_with_date.create() </span><span class="cx"> insert_dicts = [dict(zip(fnames, d)) for d in insert_data] </span><ins>+ </ins><span class="cx"> for idict in insert_dicts: </span><span class="cx"> users_with_date.insert().execute(**idict) # insert the data </span><span class="cx"> </span></span></pre> </div> </div> </body> </html> |