Here are the examples of the python api sqlalchemy.exc.NoReferencedColumnError taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
6 Examples
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_fk_no_such_target_col_error_upfront(self):
meta = MetaData()
a = Table("a", meta, Column("a", Integer))
Table("b", meta, Column("b", Integer))
a.append_constraint(ForeignKeyConstraint(["a"], ["b.x"]))
assert_raises_message(
exc.NoReferencedColumnError,
"Could not initialize target column for ForeignKey 'b.x' on "
"table 'a': table 'b' has no column named 'x'",
getattr,
list(a.foreign_keys)[0],
"column",
)
def test_fk_no_such_target_col_error_delayed(self):
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_fk_no_such_target_col_error_delayed(self):
meta = MetaData()
a = Table("a", meta, Column("a", Integer))
a.append_constraint(ForeignKeyConstraint(["a"], ["b.x"]))
Table("b", meta, Column("b", Integer))
assert_raises_message(
exc.NoReferencedColumnError,
"Could not initialize target column for ForeignKey 'b.x' on "
"table 'a': table 'b' has no column named 'x'",
getattr,
list(a.foreign_keys)[0],
"column",
)
def test_fk_mismatched_local_remote_cols(self):
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_column_accessor_string_no_target_column(self):
fk = ForeignKey("sometable.somecol")
c1 = Column("x", fk)
m = MetaData()
Table("t", m, c1)
Table("sometable", m, Column("notsomecol", Integer))
assert_raises_message(
exc.NoReferencedColumnError,
"Could not initialize target column for ForeignKey "
"'sometable.somecol' on table 't': "
"table 'sometable' has no column named 'somecol'",
getattr,
fk,
"column",
)
def test_remove_table_fk_bookkeeping(self):
0
Source : test_basic.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_inh_cond_nonexistent_col_related(self):
m = MetaData()
base_table = Table("base", m, Column("id", Integer, primary_key=True))
derived_table = Table(
"derived",
m,
Column("id", Integer, ForeignKey("base.q"), primary_key=True),
)
class Base(object):
pass
class Derived(Base):
pass
mapper(Base, base_table)
assert_raises_message(
sa_exc.NoReferencedColumnError,
"Could not initialize target column for ForeignKey "
"'base.q' on table "
"'derived': table 'base' has no column named 'q'",
mapper,
Derived,
derived_table,
inherits=Base,
)
class PKDiscriminatorTest(fixtures.MappedTest):
0
Source : test_selectable.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_join_cond_no_such_related_column(self):
m = MetaData()
t1 = Table("t1", m, Column("x", Integer, ForeignKey("t2.q")))
t2 = Table("t2", m, Column("id", Integer))
assert_raises_message(
exc.NoReferencedColumnError,
"Could not initialize target column for "
"ForeignKey 't2.q' on table 't1': "
"table 't2' has no column named 'q'",
sql_util.join_condition,
t1,
t2,
)
assert_raises_message(
exc.NoReferencedColumnError,
"Could not initialize target column for "
"ForeignKey 't2.q' on table 't1': "
"table 't2' has no column named 'q'",
sql_util.join_condition,
t2,
t1,
)
class PrimaryKeyTest(fixtures.TestBase, AssertsExecutionResults):
0
Source : test_basic.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_inh_cond_nonexistent_col_related(self):
m = MetaData()
base_table = Table("base", m, Column("id", Integer, primary_key=True))
derived_table = Table(
"derived",
m,
Column("id", Integer, ForeignKey("base.q"), primary_key=True),
)
class Base:
pass
class Derived(Base):
pass
clear_mappers()
self.mapper_registry.map_imperatively(Base, base_table)
assert_raises_message(
sa_exc.NoReferencedColumnError,
"Could not initialize target column for ForeignKey "
"'base.q' on table "
"'derived': table 'base' has no column named 'q'",
self.mapper,
Derived,
derived_table,
inherits=Base,
)
class PKDiscriminatorTest(fixtures.MappedTest):