Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
neoppod
Commits
f844fe0b
Commit
f844fe0b
authored
Feb 13, 2023
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql: minor optimization
It's been many years we don't get 'array' objects, no idea when exactly.
parent
9691459d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
24 deletions
+3
-24
neo/storage/database/mysql.py
neo/storage/database/mysql.py
+1
-4
neo/tests/storage/testStorageMySQL.py
neo/tests/storage/testStorageMySQL.py
+2
-20
No files found.
neo/storage/database/mysql.py
View file @
f844fe0b
...
@@ -221,10 +221,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -221,10 +221,7 @@ class MySQLDatabaseManager(DatabaseManager):
conn
.
query
(
query
)
conn
.
query
(
query
)
if
query
.
startswith
(
"SELECT "
):
if
query
.
startswith
(
"SELECT "
):
r
=
conn
.
store_result
()
r
=
conn
.
store_result
()
return
tuple
([
return
r
.
fetch_row
(
r
.
num_rows
())
tuple
([
d
.
tostring
()
if
isinstance
(
d
,
array
)
else
d
for
d
in
row
])
for
row
in
r
.
fetch_row
(
r
.
num_rows
())])
r
=
query
.
split
(
None
,
1
)[
0
]
r
=
query
.
split
(
None
,
1
)[
0
]
if
r
in
(
"INSERT"
,
"REPLACE"
,
"DELETE"
,
"UPDATE"
):
if
r
in
(
"INSERT"
,
"REPLACE"
,
"DELETE"
,
"UPDATE"
):
self
.
_active
=
1
self
.
_active
=
1
...
...
neo/tests/storage/testStorageMySQL.py
View file @
f844fe0b
...
@@ -63,30 +63,12 @@ class StorageMySQLdbTests(StorageDBTests):
...
@@ -63,30 +63,12 @@ class StorageMySQLdbTests(StorageDBTests):
raise
unittest
.
SkipTest
(
m
)
raise
unittest
.
SkipTest
(
m
)
return
db
return
db
def
test_query1
(
self
):
def
test_ServerGone
(
self
):
# fake result object
from
array
import
array
result_object
=
Mock
({
"num_rows"
:
1
,
"fetch_row"
:
((
1
,
2
,
array
(
'b'
,
(
1
,
2
,
))),
),
})
# expected formatted result
expected_result
=
(
(
1
,
2
,
'
\
x01
\
x02
'
,
),
)
self
.
db
.
conn
=
Mock
({
'store_result'
:
result_object
})
result
=
self
.
db
.
query
(
'SELECT '
)
self
.
assertEqual
(
result
,
expected_result
)
calls
=
self
.
db
.
conn
.
mockGetNamedCalls
(
'query'
)
self
.
assertEqual
(
len
(
calls
),
1
)
calls
[
0
].
checkArgs
(
'SELECT '
)
def
test_query2
(
self
):
with
ServerGone
(
self
.
db
)
as
p
:
with
ServerGone
(
self
.
db
)
as
p
:
self
.
assertRaises
(
ProgrammingError
,
self
.
db
.
query
,
'QUERY'
)
self
.
assertRaises
(
ProgrammingError
,
self
.
db
.
query
,
'QUERY'
)
self
.
assertFalse
(
p
.
applied
)
self
.
assertFalse
(
p
.
applied
)
def
test_
query3
(
self
):
def
test_
OperationalError
(
self
):
# OperationalError > raise DatabaseFailure exception
# OperationalError > raise DatabaseFailure exception
class
FakeConn
(
object
):
class
FakeConn
(
object
):
def
close
(
self
):
def
close
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment