Skip to content

Commit

Permalink
issue #18 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Feb 4, 2024
1 parent 6fc4dfa commit 39f139a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
18 changes: 9 additions & 9 deletions drda/ddm.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,21 @@ def read_dss(sock, db_type):
correlation_id = int.from_bytes(b[4:6], byteorder='big')
obj_ln = int.from_bytes(_recv_from_sock(sock, 2), byteorder='big')
code_point = int.from_bytes(_recv_from_sock(sock, 2), byteorder='big')

if dss_ln == 0xFFFF:
assert code_point == 0x241B # QRYDTA
if db_type == 'db2':
assert obj_ln == 32772 # ???
obj = _recv_from_sock(sock, 32757) # ???
while True:
next_ln = int.from_bytes(_recv_from_sock(sock, 2), byteorder='big')
extra = _recv_from_sock(sock, next_ln-2)
obj += extra
next_ln = int.from_bytes(_recv_from_sock(sock, 2), byteorder='big')
extra = _recv_from_sock(sock, next_ln-2)
obj += extra
elif db_type == 'derby':
obj = b''
while True:
next_ln = int.from_bytes(_recv_from_sock(sock, 4), byteorder='big')
extra = _recv_from_sock(sock, next_ln)
obj += extra
next_ln = int.from_bytes(_recv_from_sock(sock, 4), byteorder='big')
obj = _recv_from_sock(sock, 32753) # ???
next_ln = int.from_bytes(_recv_from_sock(sock, 2), byteorder='big')
extra = _recv_from_sock(sock, next_ln-2)
obj += extra
else:
obj = _recv_from_sock(sock, obj_ln - 4)
if (len(obj) != dss_ln - 10) or (obj_ln != dss_ln - 6):
Expand Down
8 changes: 4 additions & 4 deletions test_db2.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def test_issue18(self):
for _ in range(count):
cur.execute("INSERT INTO test_issue18(s) values(?)", [s])
cur.execute("SELECT * FROM test_issue18")
self.assertEqual(
list(cur.fetchall()),
[(s,) for _ in range(count)],
)
results = list(cur.fetchall())
for r in results:
self.assertEqual(r, (s,))
self.assertEqual(len(results), count)


class TestDataType(unittest.TestCase):
Expand Down
9 changes: 4 additions & 5 deletions test_derby.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ def test_double(self):
cur.execute("SELECT * FROM test_double")
self.assertEqual(cur.fetchall(), [(-1, -1, -1.0, -1.0)])

@unittest.skip
def test_issue18(self):
cur = self.connection.cursor()
try:
Expand All @@ -286,10 +285,10 @@ def test_issue18(self):
for _ in range(count):
cur.execute(f"INSERT INTO test_issue18(s) values('{s}')")
cur.execute("SELECT * FROM test_issue18")
self.assertEqual(
list(cur.fetchall()),
[(s,) for _ in range(count)],
)
results = list(cur.fetchall())
for r in results:
self.assertEqual(r, (s,))
self.assertEqual(len(results), count)

def tearDown(self):
self.connection.close()
Expand Down

0 comments on commit 39f139a

Please sign in to comment.