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

doc schema.json differs when no schema changes exist #455

Open
awhitford-cip opened this issue Mar 23, 2023 · 10 comments
Open

doc schema.json differs when no schema changes exist #455

awhitford-cip opened this issue Mar 23, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@awhitford-cip
Copy link

awhitford-cip commented Mar 23, 2023

The schema.json file generated by doc may differ between runs when no schema changes exist.

I have a workflow where doc output is generated and we look for differences. I often see differences in the schema.json file even when there were no database schema changes. Note that I am witnessing this using Snowflake.

I would expect that the schema.json file to be consistent across runs when there are no database schema changes. (Maybe the output needs to be sorted to be consistent across runs.)

Additionally, it would be nice to see this file as not one giant line so that it is easier to see the actual differences between runs. (I'm unclear on what is changing because of this property.)

@awhitford-cip awhitford-cip added the enhancement New feature or request label Mar 23, 2023
@awhitford-cip awhitford-cip changed the title schema.json differs when no schema changes exist doc schema.json differs when no schema changes exist Mar 23, 2023
@k1LoW
Copy link
Owner

k1LoW commented Apr 8, 2023

@awhitford-cip Thank you for your report

Unfortunately I do not have a Snowflake environment ( so Snowflake is experimental support).
If you have found a schema that can be reproduced in another open source database, please let me know.

@k1LoW k1LoW added bug Something isn't working and removed enhancement New feature or request labels Apr 8, 2023
@awhitford-cip
Copy link
Author

❄️ Snowflake offers a 30-day free trial.

@k1LoW
Copy link
Owner

k1LoW commented Apr 8, 2023

I have already used the trial for Snowflake support 💦

@awhitford-cip
Copy link
Author

Additionally, it would be nice to see this file as not one giant line so that it is easier to see the actual differences between runs. (I'm unclear on what is changing because of this property.)

tbls/cmd/doc.go

Line 171 in a21522e

j := json.New(true)

Why is inline set to true here? (I think if it was set to false then it would have newlines and indentation. Then it would be easier to see what changed.)

@awhitford-cip
Copy link
Author

Overall, I am going to try specifying disableOutputSchema: true to skip the schema.json file as I don't think it is necessary.

@k1LoW
Copy link
Owner

k1LoW commented Apr 24, 2023

Why is inline set to true here?

Here is why it is inline.

@MovaUA
Copy link

MovaUA commented Jan 17, 2024

Hi, Guys :)
The same issue is discovered by our CI pipelines.
We use PostgreSQL 15, tbls 1.72.0 from the docker image, the pipeline calls tbls in Ubuntu 22.04.

@k1LoW
Copy link
Owner

k1LoW commented Jan 17, 2024

@MovaUA
Could you tell which field has the difference?

@MovaUA
Copy link

MovaUA commented Jan 17, 2024

@MovaUA Could you tell which field has the difference?

First of all, I would like to say a great thanks to @k1LoW for this amazing project!
It helps us a lot to review the database changes in my project!

Sure. We found that the sorting in an array of column names in tables.constraints.columns is fluky - it kind of unpredictably produces items in different order for the tables that have not been changed.
Also, the order of column names in that array does not correspond to the actual order of the columns in the constraint.

👉 Note that we use format.sort: false in .tbls.yml

@k1LoW
Copy link
Owner

k1LoW commented Jan 17, 2024

Sure. We found that the sorting in an array of column names in tables.constraints.columns is fluky

Thank you for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants