Skip to content

Commit c5a1203

Browse files
committed
fixed VECTOR support check
1 parent d706587 commit c5a1203

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

sqlalchemy_iris/base.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ def create_cursor(self):
821821
}
822822
if sqlalchemy_version.startswith("2."):
823823
from .types import IRISUniqueIdentifier
824+
824825
colspecs[sqltypes.UUID] = IRISUniqueIdentifier
825826

826827

@@ -910,30 +911,22 @@ def on_connect(conn):
910911
if super_ is not None:
911912
super_(conn)
912913

913-
if self.embedded:
914-
self.supports_vectors = (
915-
conn.iris.cls("%SYSTEM.License").GetFeature(28) == 1
916-
)
917-
else:
918-
try:
919-
with conn.cursor() as cursor:
920-
cursor.execute(text("SELECT TO_VECTOR('1,2,3', INT, 3)"))
921-
self.supports_vectors = True
922-
except: # noqa
923-
self.supports_vectors = False
924-
if self.supports_vectors:
914+
try:
925915
with conn.cursor() as cursor:
926916
# Distance or similarity
927917
cursor.execute(
928918
"select vector_cosine(to_vector('1'), to_vector('1'))"
929919
)
930-
self.vector_cosine_similarity = cursor.fetchone()[0] == 0
931-
920+
self.supports_vectors = True
921+
except: # noqa
922+
self.supports_vectors = False
932923
self._dictionary_access = False
933924
with conn.cursor() as cursor:
934925
cursor.execute("%CHECKPRIV SELECT ON %Dictionary.PropertyDefinition")
935926
self._dictionary_access = cursor.sqlcode == 0
936927

928+
if not self.supports_vectors:
929+
util.warn("No native support for VECTOR or not activated by license")
937930
if not self._dictionary_access:
938931
util.warn(
939932
"""

0 commit comments

Comments
 (0)