summaryrefslogtreecommitdiff
path: root/test/sql/defaults.py
diff options
context:
space:
mode:
authorMichael Trier <mtrier@gmail.com>2008-10-20 15:21:00 +0000
committerMichael Trier <mtrier@gmail.com>2008-10-20 15:21:00 +0000
commitc81c7ff3d59469cf6ceccbcf1593fd0563f0eaf3 (patch)
treed12139bc6c793c7190c3fb1d344a49c37080d635 /test/sql/defaults.py
parentabcb5605f91ef206dd5f0f6400302f0b28425365 (diff)
downloadsqlalchemy-c81c7ff3d59469cf6ceccbcf1593fd0563f0eaf3.tar.gz
Modifications to allow the backends to control the behavior of an empty insert. If supports_empty_insert is True then the backend specifically supports the 'insert into t1 () values ()' syntax. If supports_default_values is True then the backend supports the 'insert into t1 default values' syntax. If both are false then the backend has no support for empty inserts at all and an exception gets raised. Changes here are careful to not change current behavior except where the current behavior was failing to begin with.
Diffstat (limited to 'test/sql/defaults.py')
-rw-r--r--test/sql/defaults.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/sql/defaults.py b/test/sql/defaults.py
index 4f0f929f1..169d60c67 100644
--- a/test/sql/defaults.py
+++ b/test/sql/defaults.py
@@ -1,8 +1,9 @@
import testenv; testenv.configure_for_tests()
import datetime
from sqlalchemy import Sequence, Column, func
+from sqlalchemy.sql import select, text
from testlib import sa, testing
-from testlib.sa import MetaData, Table, Integer, String, ForeignKey
+from testlib.sa import MetaData, Table, Integer, String, ForeignKey, Boolean
from testlib.testing import eq_
from sql import _base
@@ -472,6 +473,21 @@ class PKIncrementTest(_base.TablesTest):
con.close()
+class EmptyInsertTest(testing.TestBase):
+ @testing.exclude('sqlite', '<', (3, 3, 8), 'no empty insert support')
+ def test_empty_insert(self):
+ metadata = MetaData(testing.db)
+ t1 = Table('t1', metadata,
+ Column('is_true', Boolean, server_default=('1')))
+ metadata.create_all()
+
+ try:
+ result = t1.insert().execute()
+ self.assertEquals(1, select([func.count(text('*'))], from_obj=t1).scalar())
+ self.assertEquals(True, t1.select().scalar())
+ finally:
+ metadata.drop_all()
+
class AutoIncrementTest(_base.TablesTest):
__requires__ = ('identity',)
run_define_tables = 'each'