From: Mike Bayer Date: Wed, 18 Jul 2007 18:32:48 +0000 (+0000) Subject: - foreign key specs can have any chararcter in their identifiers X-Git-Tag: rel_0_3_10~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68f706b5bab5cd13ab77f75d1f09a32871b03031;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - foreign key specs can have any chararcter in their identifiers [ticket:667] --- diff --git a/CHANGES b/CHANGES index 81dd74e1ab..3f7f8ed319 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ - sql - got connection-bound metadata to work with implicit execution - cleanup to connection-bound sessions, SessionTransaction + - foreign key specs can have any chararcter in their identifiers + [ticket:667] + - postgres - fixed max identifier length (63) [ticket:571] diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index a6e3f5f29e..f6ad52adc2 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -727,7 +727,7 @@ class ForeignKey(SchemaItem): break else: raise exceptions.ArgumentError("Parent column '%s' does not descend from a table-attached Column" % str(self.parent)) - m = re.match(r"^([\w_-]+)(?:\.([\w_-]+))?(?:\.([\w_-]+))?$", self._colspec, re.UNICODE) + m = re.match(r"^(.+?)(?:\.(.+?))?(?:\.(.+?))?$", self._colspec, re.UNICODE) if m is None: raise exceptions.ArgumentError("Invalid foreign key column specification: " + self._colspec) if m.group(3) is None: diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index 8d62625c9a..0507b7c5b6 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -78,6 +78,27 @@ class MiscTest(AssertMixin): finally: m1.drop_all() + @testbase.supported('postgres') + def test_pg_weirdchar_reflection(self): + meta1 = MetaData(testbase.db) + subject = Table("subject", meta1, + Column("id$", Integer, primary_key=True), + ) + + referer = Table("referer", meta1, + Column("id", Integer, primary_key=True), + Column("ref", Integer, ForeignKey('subject.id$')), + ) + meta1.create_all() + try: + meta2 = MetaData(testbase.db) + subject = Table("subject", meta2, autoload=True) + referer = Table("referer", meta2, autoload=True) + print str(subject.join(referer).onclause) + self.assert_((subject.c['id$']==referer.c.ref).compare(subject.join(referer).onclause)) + finally: + meta1.drop_all() + @testbase.supported('postgres') def test_checksfor_sequence(self): meta1 = MetaData(testbase.db)