Skip to content

Commit

Permalink
implement _get_server_version_info and conditionally activate CHECK c…
Browse files Browse the repository at this point in the history
…onstraint functionality
  • Loading branch information
aris-koning committed Sep 13, 2024
1 parent 639023c commit 7b49c73
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sqlalchemy_monetdb/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ def get_multi_columns(self, connection, schema, filter_names, scope, kind, **kw)
connection, filter_names, schema, temp=temp, tabletypes=tabletypes, **kw
)

def _get_server_version_info(self, connection):
version = connection.execute(text("SELECT value FROM environment WHERE name = 'monet_version'")).scalar()
return tuple(int(part) for part in version.split('.'))

def _value_or_raise(self, data, table, schema):
try:
return dict(data)[(schema, table)]
Expand Down Expand Up @@ -917,6 +921,11 @@ def get_check_constraints(self, connection: "Connection", table_name: str, schem
.. versionadded:: 2.0.0
"""
if not self.server_version_info >= (11, 51, 3):
raise NotImplementedError(
"CHECK constraint are supported only by "
"MonetDB server 11.51.3 or greater"
)

q = """
SELECT k.name name, sys.check_constraint(:schema, k.name) sqltext
Expand Down

0 comments on commit 7b49c73

Please sign in to comment.