Skip to content

Commit ba59458

Browse files
committed
Fix for issue #4
1 parent f73726e commit ba59458

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

rdflib_sqlalchemy/SQLAlchemy.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,6 @@ def open(self, configuration, create=True):
861861
c.execute(CREATE_QUOTED_STATEMENTS_TABLE % (self._internedId))
862862
c.execute(CREATE_NS_BINDS_TABLE % (self._internedId))
863863
c.execute(CREATE_LITERAL_STATEMENTS_TABLE % (self._internedId))
864-
trans.commit()
865864
for tblName, indices in [
866865
(
867866
"%s_asserted_statements",
@@ -1676,8 +1675,8 @@ def rollback(self):
16761675
object text,
16771676
context text not NULL,
16781677
termComb integer not NULL,
1679-
objLanguage varchar(3),
1680-
objDatatype text)"""
1678+
objLanguage varchar(255),
1679+
objDatatype varchar(255))"""
16811680

16821681
CREATE_QUOTED_STATEMENTS_TABLE = """
16831682
CREATE TABLE %s_quoted_statements (
@@ -1686,8 +1685,8 @@ def rollback(self):
16861685
object text,
16871686
context text not NULL,
16881687
termComb integer not NULL,
1689-
objLanguage varchar(3),
1690-
objDatatype text)"""
1688+
objLanguage varchar(255),
1689+
objDatatype varchar(255))"""
16911690

16921691
CREATE_NS_BINDS_TABLE = """
16931692
CREATE TABLE %s_namespace_binds (

test/test_sqlalchemy_mysql.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,30 @@ def tearDown(self):
5050
def testLenInMultipleContexts(self):
5151
raise SkipTest("Known issue.")
5252

53+
54+
class SQLAMySQLIssueTestCase(unittest.TestCase):
55+
storetest = True
56+
storename = "SQLAlchemy"
57+
uri = sqlalchemy_url
58+
59+
def test_issue_4(self):
60+
from rdflib.graph import ConjunctiveGraph as Graph
61+
from rdflib.store import NO_STORE, VALID_STORE
62+
from rdflib.term import URIRef
63+
64+
ident = URIRef("rdflib_test")
65+
g = Graph(store="SQLAlchemy", identifier=ident)
66+
rt = g.open(self.uri, create=True)
67+
if rt == NO_STORE:
68+
g.open(self.uri, create=True)
69+
else:
70+
assert rt == VALID_STORE, "The underlying store is corrupt"
71+
g.destroy(self.uri)
72+
73+
5374
SQLAMySQLGraphTestCase.storetest = True
5475
SQLAMySQLContextTestCase.storetest = True
76+
SQLAMySQLIssueTestCase.storetest = True
5577

5678
if __name__ == '__main__':
5779
unittest.main()

0 commit comments

Comments
 (0)