Skip to content

fix #282: parameter parsing for association queries - #295

Closed
indiVar0508 wants to merge 1 commit into
sqlalchemy-continuum:masterfrom
indiVar0508:fix_dialect_based_param_process
Closed

indiVar0508 wants to merge 1 commit into
sqlalchemy-continuum:masterfrom
indiVar0508:fix_dialect_based_param_process

Conversation

@indiVar0508

Copy link
Copy Markdown
Contributor

attempt to address #282, to process the input parameters received in @track_association_operations method

before changes Pytest results
346 failed, 308 passed, 14 skipped, 5398 warnings, 90 errors
After Changes Pytest results
346 failed, 308 passed, 14 skipped, 5398 warnings, 90 errors

@indiVar0508

Copy link
Copy Markdown
Contributor Author

Hi @marksteward ,

Did you get a chance to review this PR ?

@marksteward

Copy link
Copy Markdown
Collaborator

Not yet.

Comment thread sqlalchemy_continuum/manager.py Resolved
Comment thread sqlalchemy_continuum/manager.py Resolved
Comment thread sqlalchemy_continuum/manager.py Resolved
@indiVar0508
indiVar0508 marked this pull request as draft August 30, 2022 03:43
@indiVar0508

indiVar0508 commented Aug 30, 2022 •

Copy link
Copy Markdown
Contributor Author

Hi @AbdealiJK @marksteward ,

Can you review changes for address_postional_agrs issue,

i was looking into this and i think new change address #295 and #283 / #284, however while deleting entries i am getting #275 not sure why it seems for delete command units_of_work is not being populated in before_flush or before_flush is not being invoked for delete commands

pytest is working similar to latest master branch
345 failed, 311 passed, 14 skipped, 302 warnings, 90 errors

i was trying with below mentioned cases

# #280
# lotr = Book(name='Lord of the rings')
# tolkien = Author(name='JRR Tolkien', books=[lotr])
# db.add(lotr)
# db.add(tolkien)
# db.commit()
# #284/#283(PR thread)
from sqlalchemy import and_
d = book_author_table.delete(whereclause=and_(book_author_table.c.author_id==1, book_author_table.c.book_id==1))
# d = book_author_table.delete()
print(d)
engine.execute(d)
db.commit()

but when delete operation is triggered the statement get processed and params also seems to be correct
{'author_id_1': 1, 'book_id_1': 1}

but i get a error with below mentioned traceback

Traceback (most recent call last):
  File "/home/indivar/github/sqlalchemy-continuum/sqlalchemy_continuum/manager.py", line 411, in append_association_operation
    uow = self.units_of_work[conn]
KeyError: <sqlalchemy.engine.base.Connection object at 0x7f5abadd7df0>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "distdemo_books.py", line 66, in <module>
    engine.execute(d)
  File "<string>", line 2, in execute
  File "/home/indivar/github/py_envs/sqlalchemy_code_update_venv/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 402, in warned
    return fn(*args, **kwargs)
  File "/home/indivar/github/py_envs/sqlalchemy_code_update_venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3257, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/home/indivar/github/py_envs/sqlalchemy_code_update_venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1380, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/home/indivar/github/py_envs/sqlalchemy_code_update_venv/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 333, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/home/indivar/github/py_envs/sqlalchemy_code_update_venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1572, in _execute_clauseelement
    ret = self._execute_context(
  File "/home/indivar/github/py_envs/sqlalchemy_code_update_venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1842, in _execute_context
    statement, parameters = fn(
  File "/home/indivar/github/py_envs/sqlalchemy_code_update_venv/lib/python3.8/site-packages/sqlalchemy/engine/events.py", line 128, in wrap_before_cursor_execute
    orig_fn(
  File "/home/indivar/github/sqlalchemy-continuum/sqlalchemy_continuum/manager.py", line 475, in track_association_operations
    self.append_association_operation(
  File "/home/indivar/github/sqlalchemy-continuum/sqlalchemy_continuum/manager.py", line 414, in append_association_operation
    uow = self.units_of_work[conn.engine]
KeyError: Engine(sqlite:///db.sqlite)

same issue also does happen for mater branch

@indiVar0508
indiVar0508 force-pushed the fix_dialect_based_param_process branch 3 times, most recently from 4eb8ed8 to 5ebcfec Compare August 31, 2022 15:28
@indiVar0508

Copy link
Copy Markdown
Contributor Author

Hi @marksteward ,

I have tidied the commits for this PR and tested the issue #282 for SQLA < 1.4, 1.3 and 1.2 it seems to works , could you review it and run travis CI Build

Pytest Run results : 346 failed, 308 passed, 14 skipped, 5398 warnings, 90 errors

@indiVar0508 indiVar0508 changed the title fix #282: datetime column in associate table based on connection dialect fix #282: parameter parsing for association queries Aug 31, 2022
@indiVar0508
indiVar0508 marked this pull request as ready for review August 31, 2022 15:40
@indiVar0508
indiVar0508 force-pushed the fix_dialect_based_param_process branch from 5ebcfec to 07af5cd Compare August 31, 2022 15:44
@indiVar0508

indiVar0508 commented Aug 31, 2022 •

Copy link
Copy Markdown
Contributor Author

It seems it is failing for postgres-native one, if you get a chance, could you also provide traceback for testcase so i will try to debug the issue locally.

Edit: just saw assertions are failing i'll try to debug this

@indiVar0508
indiVar0508 marked this pull request as draft August 31, 2022 16:21
@indiVar0508

Copy link
Copy Markdown
Contributor Author

Hi @marksteward ,

I have fixed the issue for last action job run, the job run was failing becuase in association i missed schema name consideration for table for SQLA > 1.4, i have added that now and tested with postgres in local for failing testfile(tests/relationships/test_many_to_many_relations.py) and it seems to work now.

Could you again trigger the Travis Build?

@indiVar0508
indiVar0508 marked this pull request as ready for review September 1, 2022 17:15
@indiVar0508
indiVar0508 marked this pull request as draft September 2, 2022 15:41
@indiVar0508
indiVar0508 marked this pull request as ready for review September 3, 2022 02:10
@indiVar0508

Copy link
Copy Markdown
Contributor Author

Hi @marksteward ,

The Travis Build seems to be success for this one, is there any other changes that are required for this PR or can accept the request and close it ?

this addresses #282 and #284

@AbdealiLoKo

Copy link
Copy Markdown
Contributor

Hi @indiVar0508 thanks for working on this.
I was not aware of context.compiled_parameters - it's awesome that dwlalchemy already provides this instead of us doing all the processing we were doing earlier.

Just 2 comments:

  1. Can you squash your commits as they both are solving the same thing
  2. Can you add a testcase for. The scenario where an association-table has a date field ? This was we have a testcase for the reported bug.

@marksteward can this be tagged as next-release too ? The approach seems to be clear and this is an issue for my application

@indiVar0508
indiVar0508 force-pushed the fix_dialect_based_param_process branch from c3b2be1 to d5a3eae Compare September 7, 2022 04:11
@indiVar0508

Copy link
Copy Markdown
Contributor Author

Hi @AbdealiJK ,

Updated PR with mentioned changes

@marksteward

marksteward commented Sep 7, 2022 •

Copy link
Copy Markdown
Collaborator

Hi @indiVar0508, @AbdealiJK. Yes, I love the approach, particularly getting rid of positional_args_to_dict, but I want to make sure it covers any weird corner cases. Happy to prioritise it for the next release.

@indiVar0508

Copy link
Copy Markdown
Contributor Author

Hi @marksteward,

sure if you want i can try to look into some corner cases and test it, can you give some inputs to point me the direction on what cases you want me to check i can try them locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants