diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-11-15 17:17:27 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-11-15 17:17:27 -0500 |
commit | aa3551030021dd3929237444b3a6f34cc67e4213 (patch) | |
tree | d960c60b191df4634e9e4f8247602293cd650619 /tests | |
parent | da8e3db9ec3ab96a1a90937a794122ea6c455548 (diff) | |
download | alembic-aa3551030021dd3929237444b3a6f34cc67e4213.tar.gz |
- add API support for inline literals
- push ad-hoc table/column constructs for CRUD operations
- update docs to more comprehensively describe how to do
CRUD in migrations
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_bulk_insert.py | 20 | ||||
-rw-r--r-- | tests/test_op.py | 22 |
2 files changed, 32 insertions, 10 deletions
diff --git a/tests/test_bulk_insert.py b/tests/test_bulk_insert.py index be13602..c39e815 100644 --- a/tests/test_bulk_insert.py +++ b/tests/test_bulk_insert.py @@ -1,15 +1,15 @@ from tests import _op_fixture from alembic import op -from sqlalchemy import Integer, Column, ForeignKey, \ - UniqueConstraint, Table, MetaData, String -from sqlalchemy.sql import table +from sqlalchemy import Integer, \ + UniqueConstraint, String +from sqlalchemy.sql import table, column def _test_bulk_insert(dialect, as_sql): context = _op_fixture(dialect, as_sql) t1 = table("ins_table", - Column('id', Integer, primary_key=True), - Column('v1', String()), - Column('v2', String()), + column('id', Integer), + column('v1', String()), + column('v2', String()), ) op.bulk_insert(t1, [ {'id':1, 'v1':'row v1', 'v2':'row v5'}, @@ -27,10 +27,10 @@ def test_bulk_insert(): def test_bulk_insert_wrong_cols(): context = _op_fixture('postgresql') - t1 = Table("ins_table", MetaData(), - Column('id', Integer, primary_key=True), - Column('v1', String()), - Column('v2', String()), + t1 = table("ins_table", + column('id', Integer), + column('v1', String()), + column('v2', String()), ) op.bulk_insert(t1, [ {'v1':'row v1', }, diff --git a/tests/test_op.py b/tests/test_op.py index d46f001..7503abf 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -126,4 +126,26 @@ def test_create_table_two_fk(): "FOREIGN KEY(foo_bar) REFERENCES foo (bar))" ) +def test_inline_literal(): + context = _op_fixture() + from sqlalchemy.sql import table, column + from sqlalchemy import String, Integer + account = table('account', + column('name', String), + column('id', Integer) + ) + op.execute( + account.update().\ + where(account.c.name==op.inline_literal('account 1')).\ + values({'name':op.inline_literal('account 2')}) + ) + op.execute( + account.update().\ + where(account.c.id==op.inline_literal(1)).\ + values({'id':op.inline_literal(2)}) + ) + context.assert_( + "UPDATE account SET name='account 2' WHERE account.name = 'account 1'", + "UPDATE account SET id=2 WHERE account.id = 1" + ) |