From 7b49c737e1cb746b5a1b9c69ee9d42281ca01b89 Mon Sep 17 00:00:00 2001 From: Yunus Koning Date: Fri, 13 Sep 2024 15:50:49 +0200 Subject: [PATCH] implement _get_server_version_info and conditionally activate CHECK constraint functionality --- sqlalchemy_monetdb/dialect.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sqlalchemy_monetdb/dialect.py b/sqlalchemy_monetdb/dialect.py index 052f0b6..4db891d 100644 --- a/sqlalchemy_monetdb/dialect.py +++ b/sqlalchemy_monetdb/dialect.py @@ -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)] @@ -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