Skip to content

Commit 8809648

Browse files
committed
Track version series instead of exact version
Track the version with the minor release truncated. E.g. both SQLAlchemy 1.4.25 and SQLAlchemy 1.4.24 will be registered as the hash of SQLAlchemy 1.4.
1 parent b0d1085 commit 8809648

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sqlalchemy_cockroachdb/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,22 @@ def initialize(self, connection):
148148
# The crdb_internal.increment_feature_counter only exists in v21.1 of CRDB
149149
# and onwards.
150150
if self._is_v211plus and not self.disable_cockroachdb_telemetry:
151+
sqlalchemy_version_string = ""
151152
dialect_version = pkg_resources.require("sqlalchemy-cockroachdb")[0].version
152153
sqlalchemy_version = pkg_resources.require("sqlalchemy")[0].version
154+
matches = re.findall(r"(\d+\.\d+)(\.|$)", sqlalchemy_version)
155+
if len(matches) == 0:
156+
sqlalchemy_version_string = sqlalchemy_version
157+
else:
158+
sqlalchemy_version_string = matches[0][0]
153159
telemetry_query = "SELECT crdb_internal.increment_feature_counter(:val)"
154160
connection.execute(
155161
text(telemetry_query),
156162
dict(val=f'sqlalchemy-cockroachdb {dialect_version}')
157163
)
158164
connection.execute(
159165
text(telemetry_query),
160-
dict(val=f'sqlalchemy {sqlalchemy_version}')
166+
dict(val=f'sqlalchemy {sqlalchemy_version_string}')
161167
)
162168

163169
def _get_server_version_info(self, conn):

0 commit comments

Comments
 (0)