-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #238: handling version_table from option method #280
base: master
Are you sure you want to change the base?
Conversation
Hi @marksteward , Could review this PR ? Travis does not seem to be running it says
if you could run them i could fix the new issues coming in Build, it's running in my local. |
Thanks for this, unfortunately tests are currently failing and I'll need to find some time to fix that before I can merge this. |
@marksteward This seems to be a blocker for me right now Cause I have a case where I have 2 tables: When I set the But This seems to be a significant bug - and I could not find a workaround for it |
Added test file for |
I tidied this up only to find the first commit breaks tests. Could you take a look at these errors? |
Hi, Can you check now i updated this branch with latest merge from master to use updated latest testcases, could you reivew this? Pytest result with upstream master branch |
ee3b86c
to
5b72c11
Compare
I appreciate this is a breaking bug for you, and I'd like to get the fix out. However, this also changes the interface of a publicly documented function so it should ideally go in the next major release. Are you still able to work around this issue in your own code? I've cherry-picked the |
Oops, just seen the scalar_subquery bit is duplicated by #300. |
Hi @marksteward ,
I think we can avoid going this route, as #299 helps address this issue better it seems, if it gets merged then we can modify the version_table method to something like this and it should work
Can you merge #299 so i'll pull and make changes and test locally for this one which could address and close #238 |
Yep - I agree. |
6b8a05d
to
7910f83
Compare
Add Table.__versioning_manager__ so we can keep track of the manager used for a table. Allow table in get_versioning_manager() Also add unittests for the function
7910f83
to
9647244
Compare
I have updated the PR with solution used in #299 and it seems to work added more testcases to cover version_table scenerios you can review the changes once. |
sqlalchemy_continuum/manager.py
Outdated
try: | ||
return model.__versioned__[name] | ||
return model_or_table.__versioned__[name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are now 3 cases:
- Input is a model
- Input is a table which belongs to a model
- Input is an assoc table (doesn't have a model)
In scenario 2 - we are not handling it correctly, because we should be using the model's options (if available)
This would be clearer to read and use I think:
if isinstance(model_or_table, sa.Table):
table = model_or_table
if table in self.association_tables:
return self.options[name]
else:
try:
model_or_table = GET_MODEL(table)
except NoModelFound:
raise TypeError('Table %r is not versioned.' % table)
else:
model = model_or_table
if not hasattr(model, '__versioned__'):
raise TypeError('Model %r is not versioned.' % model_or_table)
try:
return model_or_table.__versioned__[name]
except KeyError:
return self.options[name]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @AbdealiJK ,
Tried to address this added testcase as well added a model attr to table in table_builder for this
9e4a3b5
to
ffb3c64
Compare
ffb3c64
to
4cd781f
Compare
hey @indiVar0508, is there anything i can do to help this get merged and released? my team would love to be able to customize our table names but we're blocked by this |
whoops, meant to tag @marksteward - let me know if there's anything i can do to help with either this or #280 |
I was also running into this problem locally and this branch has fixed it for me. I'd love to see this merged as well. |
Hi,
Raising PR in reference to issue #238, as per solution suggested by @aditya051293 .
complete commit message: Fix #238: handling hardcoded string with options.tablename attribute via version_manager
Along with above change i was getting an SAWarning showing
sqlalchemy_continuum/relationship_builder.py:51: SAWarning: implicitly coercing SELECT object to scalar subquery; please use the .scalar_subquery() method to produce a scalar subquery. return getattr(self.remote_cls, tx_column) == (
have used same solution used by @TomGoBravo in PR #269 ,
complete commit message: fix for relationship_builder.py:51 SAWarning: implicitly coercing SELECT object to scalar subquery
could you please review if changes are ok?
Thanks