Skip to content

Commit aaae816

Browse files
committed
use Index construct instead of UniqueConstraint in order to pass mysql_length param
1 parent 28d8ed4 commit aaae816

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

rdflib_sqlalchemy/tables.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from sqlalchemy import Column, Table, Index, UniqueConstraint, types
1+
from sqlalchemy import Column, Table, Index, types
22

33
from rdflib_sqlalchemy.types import TermType
44

@@ -48,12 +48,14 @@ def create_asserted_statements_table(interned_id, metadata):
4848
"{interned_id}_A_termComb_index".format(interned_id=interned_id),
4949
"termComb",
5050
),
51-
UniqueConstraint(
51+
Index(
52+
"{interned_id}_asserted_spoc_key".format(interned_id=interned_id),
5253
"subject",
5354
"predicate",
5455
"object",
5556
"context",
56-
name="{interned_id}_asserted_spoc_key",
57+
unique=True,
58+
mysql_length=MYSQL_MAX_INDEX_LENGTH,
5759
),
5860
)
5961

@@ -86,11 +88,13 @@ def create_type_statements_table(interned_id, metadata):
8688
"{interned_id}_T_termComb_index".format(interned_id=interned_id),
8789
"termComb",
8890
),
89-
UniqueConstraint(
91+
Index(
92+
"{interned_id}_type_mkc_key".format(interned_id=interned_id),
9093
"member",
9194
"klass",
9295
"context",
93-
name="{interned_id}_type_mkc_key",
96+
unique=True,
97+
mysql_length=MYSQL_MAX_INDEX_LENGTH,
9498
),
9599
)
96100

@@ -126,12 +130,14 @@ def create_literal_statements_table(interned_id, metadata):
126130
"{interned_id}_L_termComb_index".format(interned_id=interned_id),
127131
"termComb",
128132
),
129-
UniqueConstraint(
133+
Index(
134+
"{interned_id}_literal_spoc_key".format(interned_id=interned_id),
130135
"subject",
131136
"predicate",
132137
"object",
133138
"context",
134-
name="{interned_id}_literal_spoc_key",
139+
unique=True,
140+
mysql_length=MYSQL_MAX_INDEX_LENGTH,
135141
),
136142
)
137143

@@ -172,12 +178,14 @@ def create_quoted_statements_table(interned_id, metadata):
172178
"{interned_id}_Q_termComb_index".format(interned_id=interned_id),
173179
"termComb",
174180
),
175-
UniqueConstraint(
181+
Index(
182+
"{interned_id}_quoted_spoc_key".format(interned_id=interned_id),
176183
"subject",
177184
"predicate",
178185
"object",
179186
"context",
180-
name="{interned_id}_quoted_spoc_key",
187+
unique=True,
188+
mysql_length=MYSQL_MAX_INDEX_LENGTH,
181189
),
182190
)
183191

rdflib_sqlalchemy/types.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from rdflib.graph import Graph, QuotedGraph
22
from rdflib.term import Node
33
from six import text_type
4-
from sqlalchemy.dialects import mysql
54
from sqlalchemy import types
65

76

87
class TermType(types.TypeDecorator):
98
"""Term typology."""
109

11-
impl = types.Text().with_variant(mysql.TEXT(255), "mysql")
10+
impl = types.Text()
1211

1312
def process_bind_param(self, value, dialect):
1413
"""Process bound parameters."""

0 commit comments

Comments
 (0)