- Session.bind gets used as a default even when table/mapper
specific binds are defined.
+- schema
+ - Added prefixes option to `Table` that accepts a list of
+ strings to insert after CREATE in the CREATE TABLE statement.
+ [ticket:1075]
+
- sqlite
- Modified SQLite's representation of "microseconds" to
match the output of str(somedatetime), i.e. in that the
been defined elsewhere in the application, else an exception is
raised.
+ prefixes
+ A list of strings to insert after CREATE in the CREATE TABLE
+ statement. They will be separated by spaces.
+
useexisting
Defaults to False: indicates that if this Table was already
defined elsewhere in the application, disregard the rest of the
if kwargs.get('info'):
self._info = kwargs.pop('info')
+ self._prefixes = kwargs.pop('prefixes', [])
+
self.__extra_kwargs(**kwargs)
# load column definitions from the database if 'autoload' is defined
import testenv; testenv.configure_for_tests()
import pickle
-from sqlalchemy import MetaData
+from sqlalchemy import MetaData, create_engine
from testlib.sa import Table, Column, Integer, String, UniqueConstraint, \
CheckConstraint, ForeignKey
import testlib.sa as tsa
'fake_table',
MetaData(testing.db), autoload=True)
+
+class TableOptionsTest(TestBase):
+ def mock_engine(self):
+ buffer = []
+ def executor(sql, *a, **kw):
+ buffer.append(sql)
+ engine = create_engine(testing.db.name + '://',
+ strategy='mock', executor=executor)
+ assert not hasattr(engine, 'mock')
+ engine.mock = buffer
+ return engine
+
+ def setUp(self):
+ self.engine = self.mock_engine()
+ self.metadata = MetaData(self.engine)
+
+ def test_prefixes(self):
+ table1 = Table("temporary_table_1", self.metadata,
+ Column("col1", Integer),
+ prefixes = ["TEMPORARY"])
+ table1.create()
+ assert [str(x) for x in self.engine.mock if 'CREATE TEMPORARY TABLE' in str(x)]
+ del self.engine.mock[:]
+ table2 = Table("temporary_table_2", self.metadata,
+ Column("col1", Integer),
+ prefixes = ["VIRTUAL"])
+ table2.create()
+ assert [str(x) for x in self.engine.mock if 'CREATE VIRTUAL TABLE' in str(x)]
+
if __name__ == '__main__':
testenv.main()