Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an AttributeError when calling an attribute of _SpatialElement … #238

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions geoalchemy2/elements.py
Expand Up @@ -61,6 +61,13 @@ def __getattr__(self, name):
# ST_Buffer(ST_GeomFromWKB(:ST_GeomFromWKB_1), :param_1)
#

# Function names that don't start with "ST_" are rejected.
# This is not to mess up with SQLAlchemy's use of
# hasattr/getattr on Column objects.

if not name.lower().startswith('st_'):
raise AttributeError

# We create our own _FunctionGenerator here, and use it in place of
# SQLAlchemy's "func" object. This is to be able to "bind" the
# function to the SQL expression. See also GenericFunction above.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_functional.py
Expand Up @@ -256,7 +256,7 @@ def test_select_bindparam_WKBElement_extented(self):
rows = results.fetchall()
geom = rows[0][1]
assert isinstance(geom, WKBElement)
assert geom.extented
assert geom.extended is True

s = Lake.__table__.select().where(Lake.__table__.c.geom == bindparam('geom'))
results = self.conn.execute(s, geom=geom)
Expand Down Expand Up @@ -375,7 +375,7 @@ def test_pickle_unpickle(self):
unpickled = pickle.loads(pickled)
assert unpickled.geom.srid == 4326
assert str(unpickled.geom) == data_desc
assert unpickled.geom.extended
assert unpickled.geom.extended is True
assert unpickled.geom.name == 'ST_GeomFromEWKB'


Expand Down