-
Notifications
You must be signed in to change notification settings - Fork 39
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
[Feature Request] Generate tests that can check against an actual postgres schema #274
Comments
This would be immensely helpful, as it's very easy to make a mistake when writing the Haskell types. |
Quick and dirty poc https://gist.github.com/KaneTW/0f321b6ccf0143611c43e2d087e939d3 Basically checks if the types match (i.e. bidirectional casts exists, so varchar and text match, but int8 and int2 don't), all non-nullables are present, and the hs ty has no extraneous types. |
This is a temporary attempt. See related issues: - [Feature Request] Generate tests that can check against an actual postgres schema circuithub#274 [1] - Provide access to rel8 internals circuithub#291 [2] [1]: circuithub#274 [2]: circuithub#291
Thanks a ton! This was super helpful. If only #291 would become a reality. I had to fork Rel8 like you apparently did. |
Glad this helped. And a way to extract the schemas using the GHC API (at least as of writing that code half a year ago, this was not possible with any other method). Can also list them manually, but I found that too error-prone. Runs like this: |
That's getting better 😃 Thanks! |
@KaneTW is this correct for tables which contain I'm still working through figuring out the internals though, so I'm not sure if it's a bug in your gist, or a bug in the way rel8 reports the information, or a bug in my own code, though I don't think it's the latter, simply because I've been relying on this schema for a while, and everything has been working fine (as far as I can tell). |
Honestly not sure. It was correct when I used it, but it could have been a case I hadn't encountered. It's been too long so I'd have to dig into the code as well to understand it again. |
I think it might be an issue of |
This closes circuithub#274 and circuithub#186, allowing the generation of CREATE TABLE statements from a TableSchema, as well as testing the table's schema in the database against the schema implied by the TableSchema type. Co-authored-by: David Kraeutmann <[email protected]>
This closes circuithub#274 and circuithub#186, allowing the generation of CREATE TABLE statements from a TableSchema, as well as testing the table's schema in the database against the schema implied by the TableSchema type. Co-authored-by: David Kraeutmann <[email protected]>
This closes circuithub#274 and circuithub#186, allowing the generation of CREATE TABLE statements from a TableSchema, as well as checking a TableSchema against a database to determine if the tables are defined correctly in the database to be read from/written to by rel8. It also adds tests for the creation and type checking of tables, to ensure they succeed/fail in appropriate cases. Co-authored-by: David Kraeutmann <[email protected]>
It would be really nice to be able to be able to generate a test suite that will connect to a local postgres instance and verify that all
TableSchema
types match the postgres database's schema.I am imagining that you would register each table schema in a list and maybe provide a pg connection string or something, and then the tests would be generated.
I am happy to help implement this, but I would definitely need lots of direction.
The text was updated successfully, but these errors were encountered: