sqlalchemy-singlestoredb 1.2.0__tar.gz → 1.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {sqlalchemy_singlestoredb-1.2.0/sqlalchemy_singlestoredb.egg-info → sqlalchemy_singlestoredb-1.2.1}/PKG-INFO +1 -1
  2. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/pyproject.toml +1 -1
  3. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/__init__.py +1 -1
  4. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/base.py +1 -1
  5. sqlalchemy_singlestoredb-1.2.1/sqlalchemy_singlestoredb/column.py +126 -0
  6. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/ddlelement.py +516 -61
  7. sqlalchemy_singlestoredb-1.2.1/sqlalchemy_singlestoredb/dtypes.py +257 -0
  8. sqlalchemy_singlestoredb-1.2.1/sqlalchemy_singlestoredb/tests/test_json_type.py +238 -0
  9. sqlalchemy_singlestoredb-1.2.1/sqlalchemy_singlestoredb/tests/test_persisted_column.py +282 -0
  10. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_shard_key.py +91 -0
  11. sqlalchemy_singlestoredb-1.2.1/sqlalchemy_singlestoredb/tests/test_vector_type.py +319 -0
  12. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1/sqlalchemy_singlestoredb.egg-info}/PKG-INFO +1 -1
  13. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb.egg-info/SOURCES.txt +4 -1
  14. sqlalchemy_singlestoredb-1.2.0/sqlalchemy_singlestoredb/column.py +0 -26
  15. sqlalchemy_singlestoredb-1.2.0/sqlalchemy_singlestoredb/dtypes.py +0 -110
  16. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/LICENSE +0 -0
  17. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/README.md +0 -0
  18. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/setup.cfg +0 -0
  19. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/compat.py +0 -0
  20. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/examples/shard_key_examples.py +0 -0
  21. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/examples/table_constructor_examples.py +0 -0
  22. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/examples/universal/main.py +0 -0
  23. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/reflection.py +0 -0
  24. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/__init__.py +0 -0
  25. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/conftest.py +0 -0
  26. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/run_all_tests.py +0 -0
  27. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test.sql +0 -0
  28. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_advanced_indexes.py +0 -0
  29. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_basics.py +0 -0
  30. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_column_group.py +0 -0
  31. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_database_fixtures.py +0 -0
  32. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_declarative_reflection.py +0 -0
  33. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_error_handling.py +0 -0
  34. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_error_handling_pytest.py +0 -0
  35. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_integration_features.py +0 -0
  36. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_key_reflection.py +0 -0
  37. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_priority1_features.py +0 -0
  38. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_sort_key.py +0 -0
  39. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_table_options.py +0 -0
  40. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_table_types.py +0 -0
  41. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb/tests/test_vector_key.py +0 -0
  42. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb.egg-info/dependency_links.txt +0 -0
  43. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb.egg-info/entry_points.txt +0 -0
  44. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb.egg-info/requires.txt +0 -0
  45. {sqlalchemy_singlestoredb-1.2.0 → sqlalchemy_singlestoredb-1.2.1}/sqlalchemy_singlestoredb.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlalchemy_singlestoredb
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: SQLAlchemy dialect for the SingleStoreDB database
5
5
  Author-email: SingleStore <support@singlestore.com>
6
6
  License: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'
4
4
 
5
5
  [project]
6
6
  name = 'sqlalchemy_singlestoredb'
7
- version = '1.2.0'
7
+ version = '1.2.1'
8
8
  description = 'SQLAlchemy dialect for the SingleStoreDB database'
9
9
  readme = 'README.md'
10
10
  requires-python = '>=3.9'
@@ -57,7 +57,7 @@ array = base.array
57
57
  # default dialect
58
58
  dialect = base.dialect
59
59
 
60
- __version__ = '1.2.0'
60
+ __version__ = '1.2.1'
61
61
 
62
62
  __all__ = (
63
63
  'BIGINT',
@@ -457,7 +457,7 @@ class SingleStoreDBDDLCompiler(MySQLDDLCompiler):
457
457
  'AS',
458
458
  column.persisted_expression,
459
459
  'PERSISTED',
460
- self.dialect.type_compiler_instance.process(
460
+ self.dialect.type_compiler.process(
461
461
  column.type, type_expression=column,
462
462
  ),
463
463
  ]
@@ -0,0 +1,126 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from sqlalchemy import Column
6
+ from sqlalchemy.sql.expression import TextClause
7
+
8
+
9
+ class PersistedColumn(Column):
10
+ """SingleStore computed column that is automatically calculated and stored.
11
+
12
+ PersistedColumn defines computed columns based on an expression. The computed
13
+ value is persisted to disk and updated when dependent columns change.
14
+
15
+ Parameters
16
+ ----------
17
+ name : str
18
+ Column name
19
+ type_ : TypeEngine
20
+ SQLAlchemy type for the computed value
21
+ persisted_expression : str or TextClause
22
+ SQL expression to compute the column value
23
+ *args, **kwargs
24
+ Additional arguments passed to Column
25
+
26
+ Examples
27
+ --------
28
+ Basic computed column:
29
+
30
+ >>> PersistedColumn('total', Integer, persisted_expression='price * quantity')
31
+
32
+ Using TextClause for complex expressions:
33
+
34
+ >>> from sqlalchemy import text
35
+ >>> PersistedColumn('full_name', String(101),
36
+ ... persisted_expression=text("CONCAT(first_name, ' ', last_name)"))
37
+
38
+ **Table Usage:**
39
+
40
+ .. code-block:: python
41
+
42
+ from sqlalchemy import Column, Integer, MetaData, String, Table, text
43
+ from sqlalchemy_singlestoredb import PersistedColumn
44
+
45
+ metadata = MetaData()
46
+
47
+ products = Table(
48
+ 'products', metadata,
49
+ Column('id', Integer, primary_key=True),
50
+ Column('price', Integer),
51
+ Column('quantity', Integer),
52
+ PersistedColumn(
53
+ 'total',
54
+ Integer,
55
+ persisted_expression='price * quantity',
56
+ ),
57
+ )
58
+
59
+ users = Table(
60
+ 'users', metadata,
61
+ Column('id', Integer, primary_key=True),
62
+ Column('first_name', String(50)),
63
+ Column('last_name', String(50)),
64
+ PersistedColumn(
65
+ 'full_name',
66
+ String(101),
67
+ persisted_expression=text("CONCAT(first_name, ' ', last_name)"),
68
+ ),
69
+ )
70
+
71
+ **ORM Usage:**
72
+
73
+ In ORM models, PersistedColumn is used directly as a class attribute,
74
+ just like a regular Column:
75
+
76
+ .. code-block:: python
77
+
78
+ from sqlalchemy import Column, Integer, String
79
+ from sqlalchemy.orm import declarative_base
80
+ from sqlalchemy_singlestoredb import PersistedColumn
81
+
82
+ Base = declarative_base()
83
+
84
+ class Product(Base):
85
+ __tablename__ = 'products'
86
+
87
+ id = Column(Integer, primary_key=True)
88
+ price = Column(Integer)
89
+ quantity = Column(Integer)
90
+ total = PersistedColumn(
91
+ 'total',
92
+ Integer,
93
+ persisted_expression='price * quantity',
94
+ )
95
+
96
+ class User(Base):
97
+ __tablename__ = 'users'
98
+
99
+ id = Column(Integer, primary_key=True)
100
+ first_name = Column(String(50))
101
+ last_name = Column(String(50))
102
+ full_name = PersistedColumn(
103
+ 'full_name',
104
+ String(101),
105
+ persisted_expression="CONCAT(first_name, ' ', last_name)",
106
+ )
107
+
108
+ """
109
+
110
+ def __init__(
111
+ self,
112
+ *args: Any,
113
+ persisted_expression: Any = None,
114
+ **kwargs: Any,
115
+ ) -> None:
116
+ if persisted_expression is not None:
117
+ # Ensure persisted_expression is either a TextClause or a string
118
+ if not isinstance(persisted_expression, (TextClause, str)):
119
+ raise ValueError(
120
+ 'Persisted expression must be a SQL expression '
121
+ 'as a string or TextClause',
122
+ )
123
+ self.is_persisted = True
124
+ self.persisted_expression = persisted_expression
125
+ kwargs['info'] = {'persisted_expression': persisted_expression}
126
+ super().__init__(*args, **kwargs)