Skip to content
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

get_output_schema exception with table name #449

Merged
merged 12 commits into from
Mar 6, 2022
Merged

get_output_schema exception with table name #449

merged 12 commits into from
Mar 6, 2022

Conversation

AliSayyah
Copy link
Member

get_output_schema will raise an exception with the name of the corresponding table if something goes wrong while generating the tables.
based on #447

Another alternative would be to add the errors attribute to the OutputSchema class and handle it like how warnings are being addressed.

…ponding table if something goes wrong while generating the tables.
@AliSayyah
Copy link
Member Author

The test works in python 3.10 (and 3.9 in local) but not with 3.7.
I have to figure out what functionality changed in these versions.

@dantownsend
Copy link
Member

I think something changed with mocks in > Python 3.7.

I've been caught out by this many times.

@AliSayyah
Copy link
Member Author

https://docs.python.org/3/library/unittest.mock.html#unittest.mock.AsyncMock

I think this is it. create_table_class_from_db is an async function and mock handles it in >=3.8 as a coroutine.

@dantownsend
Copy link
Member

@AliSayyah If you search for set_mock_return_value in the Piccolo codebase, there's something there which should help.

@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2022

Codecov Report

Merging #449 (396c9ec) into master (b384f71) will decrease coverage by 0.10%.
The diff coverage is 73.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #449      +/-   ##
==========================================
- Coverage   90.84%   90.74%   -0.11%     
==========================================
  Files         103      104       +1     
  Lines        6870     6902      +32     
==========================================
+ Hits         6241     6263      +22     
- Misses        629      639      +10     
Impacted Files Coverage Δ
piccolo/apps/schema/commands/generate.py 88.96% <70.58%> (-2.47%) ⬇️
piccolo/apps/schema/commands/exceptions.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b384f71...396c9ec. Read the comment docs.

@AliSayyah
Copy link
Member Author

@dantownsend I think this is ready for review,

@dantownsend
Copy link
Member

@AliSayyah Cool, thanks

@dantownsend
Copy link
Member

@AliSayyah This looks great thanks.

I pushed a few extra commits:

  • I decided to use your AsyncMock implementation everywhere, and removed set_mock_return_value, as I think your solution is more intuitive.
  • I took this opportunity to improve error handling if indexes couldn't be parsed (related to piccolo schema generate crash on index parse.  #363)

@AliSayyah
Copy link
Member Author

AliSayyah commented Mar 6, 2022

Thank you this is great!
I think adding a test for index_warnings could be a good idea. If you think it is necessary, I can add it tommorow.

@dantownsend
Copy link
Member

@AliSayyah Yeah, it could do with a unit test really. I'm happy to release as is, but if you wouldn't mind doing a separate PR to add a test, that would be great.

@AliSayyah
Copy link
Member Author

@AliSayyah Yeah, it could do with a unit test really. I'm happy to release as is, but if you wouldn't mind doing a separate PR to add a test, that would be great.

Yeah, I'll open another PR👍.

@dantownsend
Copy link
Member

@AliSayyah thanks

@dantownsend dantownsend merged commit 527f163 into piccolo-orm:master Mar 6, 2022
@AliSayyah AliSayyah deleted the generation_exceptions branch March 6, 2022 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants