"and will cause errors in some cases. Version 2.1.3 "
"or greater is recommended.") %
'.'.join([str(subver) for subver in sqlite_ver]))
+ if self.dbapi.sqlite_version_info < (3, 3, 8):
+ self.supports_default_values = False
self.supports_cast = (self.dbapi is None or vers(self.dbapi.sqlite_version) >= vers("3.2.3"))
def dbapi(cls):
preparer = self.preparer
if not colparams:
- return "INSERT INTO %s DEFAULT VALUES" % (
- (preparer.format_table(insert_stmt.table),))
+ if not self.dialect.supports_default_values:
+ raise exc.NotSupportedError(
+ "The version of SQLite you are using, %s, does not support DEFAULT VALUES." % (self.dialect.dbapi.sqlite_version))
+
+ return ("INSERT INTO %s DEFAULT VALUES" % (
+ (preparer.format_table(insert_stmt.table),)))
else:
return ("INSERT INTO %s (%s) VALUES (%s)" %
(preparer.format_table(insert_stmt.table),
__only_on__ = 'sqlite'
# empty insert (i.e. INSERT INTO table DEFAULT VALUES)
- # fails as recently as sqlite 3.3.6. passes on 3.4.1. this syntax
- # is nowhere to be found in the sqlite3 documentation or changelog, so can't
- # determine what versions in between it's legal for.
+ # fails on 3.3.7 and before
def _test_empty_insert(self, table, expect=1):
try:
table.create()
finally:
table.drop()
- @testing.exclude('sqlite', '<', (3, 4), 'no database support')
+ @testing.exclude('sqlite', '<', (3, 3, 8), 'no database support')
def test_empty_insert_pk1(self):
self._test_empty_insert(
Table('a', MetaData(testing.db),
Column('id', Integer, primary_key=True)))
- @testing.exclude('sqlite', '<', (3, 4), 'no database support')
+ @testing.exclude('sqlite', '<', (3, 3, 8), 'no database support')
def test_empty_insert_pk2(self):
self.assertRaises(
exc.DBAPIError,
Column('x', Integer, primary_key=True),
Column('y', Integer, primary_key=True)))
- @testing.exclude('sqlite', '<', (3, 4), 'no database support')
+ @testing.exclude('sqlite', '<', (3, 3, 8), 'no database support')
def test_empty_insert_pk3(self):
self.assertRaises(
exc.DBAPIError,
Column('y', Integer, DefaultClause('123'),
primary_key=True)))
- @testing.exclude('sqlite', '<', (3, 4), 'no database support')
+ @testing.exclude('sqlite', '<', (3, 3, 8), 'no database support')
def test_empty_insert_pk4(self):
self._test_empty_insert(
Table('d', MetaData(testing.db),
Column('x', Integer, primary_key=True),
Column('y', Integer, DefaultClause('123'))))
- @testing.exclude('sqlite', '<', (3, 4), 'no database support')
+ @testing.exclude('sqlite', '<', (3, 3, 8), 'no database support')
def test_empty_insert_nopk1(self):
self._test_empty_insert(
Table('e', MetaData(testing.db),
Column('id', Integer)))
- @testing.exclude('sqlite', '<', (3, 4), 'no database support')
+ @testing.exclude('sqlite', '<', (3, 3, 8), 'no database support')
def test_empty_insert_nopk2(self):
self._test_empty_insert(
Table('f', MetaData(testing.db),