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

support filtering table definitions #39

Merged
merged 12 commits into from
Oct 10, 2022
Merged

Conversation

youpy
Copy link
Contributor

@youpy youpy commented Oct 7, 2022

Added a mechanism to exclude unsupported table definitions, example for use with sqlite3 adapters that do not support ADD CONSTRAINT when changing the table schema.

@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (dab7671) compared to base (2a66d51).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head dab7671 differs from pull request most recent head 32ff567. Consider uploading reports for the commit 32ff567 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #39   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          614       625   +11     
=========================================
+ Hits           614       625   +11     
Impacted Files Coverage Δ
builder/table.go 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

builder/table.go Outdated
result := []rel.TableDefinition{}

for _, def := range table.Definitions {
if t.DefinitionFilter == nil || t.DefinitionFilter(table, def) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to move t.DefinitionFilter == nil as early return before calling this loop

if t.DefinitionFilter == nil {
  return table.Definitions
}

table: rel.Table{
Op: rel.SchemaAlter,
Name: "columns",
Definitions: []rel.TableDefinition{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just filter out silently like this? or do you think it's better to print some log? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to have some way to inform users.

Copy link
Contributor Author

@youpy youpy Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be sufficient to output logs in the DefinitionFilter like this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, something like that should be sufficient

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @youpy, could you add the log as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I just added.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the log will be inside definitions functions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I misunderstood
added (53e002a)

@Fs02
Copy link
Member

Fs02 commented Oct 7, 2022

Thank you for this PR
just want to know, are you planning to open PR in sqlite3 repo as well?

@youpy
Copy link
Contributor Author

youpy commented Oct 7, 2022

Thank you for this PR just want to know, are you planning to open PR in sqlite3 repo as well?

Yes, but I haven't written any code yet

builder/table.go Outdated
result = append(result, def)
} else {
log.Print("[REL] An unsupported table definition has been excluded")
log.Print("[REL] An unsupported table definition has been excluded: " + reason)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't it be simpler if we just use: log.Printf("[REL] ....: %T", def)?

Copy link
Member

@Fs02 Fs02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you

@Fs02 Fs02 merged commit 1a68ed2 into go-rel:main Oct 10, 2022
@youpy youpy deleted the table-definition-filter branch October 10, 2022 12:51
@Fs02
Copy link
Member

Fs02 commented Oct 11, 2022

Thank you for this PR just want to know, are you planning to open PR in sqlite3 repo as well?

Yes, but I haven't written any code yet

please use sql@master go get github.com/go-rel/sql@master when developing in sqlite3 repo, I'll adjust the version later

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.

None yet

2 participants