"retryable" condition. Only Oracle ORA-01033
implemented for now. [ticket:2201]
+- sqlite
+ - SQLite dialect no longer strips quotes
+ off of reflected default value, allowing
+ a round trip CREATE TABLE to work.
+ This is consistent with other dialects
+ that also maintain the exact form of
+ the default. [ticket:2189]
+
- postgresql
- Added new "postgresql_ops" argument to
Index, allows specification of PostgreSQL
else:
pragma = "PRAGMA "
qtable = quote(table_name)
- c = _pragma_cursor(connection.execute("%stable_info(%s)" % (pragma, qtable)))
+ c = _pragma_cursor(
+ connection.execute("%stable_info(%s)" %
+ (pragma, qtable)))
found_table = False
columns = []
while True:
row = c.fetchone()
if row is None:
break
- (name, type_, nullable, default, has_default, primary_key) = (row[1], row[2].upper(), not row[3], row[4], row[4] is not None, row[5])
+ (name, type_, nullable, default, has_default, primary_key) = \
+ (row[1], row[2].upper(), not row[3],
+ row[4], row[4] is not None, row[5])
name = re.sub(r'^\"|\"$', '', name)
- if default:
- default = re.sub(r"^\'|\'$", '', default)
match = re.match(r'(\w+)(\(.*?\))?', type_)
if match:
coltype = match.group(1)
from sqlalchemy.engine.url import make_url
from test.lib import *
import os
+from sqlalchemy.schema import CreateTable
class TestTypes(fixtures.TestBase, AssertsExecutionResults):
assert isinstance(t2.c.y.type, sqltypes.NullType)
-class TestDefaults(fixtures.TestBase, AssertsExecutionResults):
+class DefaultsTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'sqlite'
db = testing.db
m = MetaData(db)
- expected = ['my_default', '0']
+ expected = ["'my_default'", '0']
table = \
"""CREATE TABLE r_defaults (
data VARCHAR(40) DEFAULT 'my_default',
finally:
db.execute('DROP TABLE r_defaults')
+ def test_default_reflection_3(self):
+ db = testing.db
+ table = \
+ """CREATE TABLE r_defaults (
+ data VARCHAR(40) DEFAULT 'my_default',
+ val INTEGER NOT NULL DEFAULT 0
+ )"""
+ try:
+ db.execute(table)
+ m1 = MetaData(db)
+ t1 = Table('r_defaults', m1, autoload=True)
+ db.execute("DROP TABLE r_defaults")
+ t1.create()
+ m2 = MetaData(db)
+ t2 = Table('r_defaults', m2, autoload=True)
+ self.assert_compile(
+ CreateTable(t2),
+ "CREATE TABLE r_defaults (data VARCHAR(40) "
+ "DEFAULT 'my_default', val INTEGER DEFAULT 0 "
+ "NOT NULL)"
+ )
+ finally:
+ db.execute("DROP TABLE r_defaults")
+
class DialectTest(fixtures.TestBase, AssertsExecutionResults):