-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Auto generate table name #3637
base: develop
Are you sure you want to change the base?
Auto generate table name #3637
Conversation
db/sql/00_msar.sql
Outdated
fq_table_name := format('%I.%I', schema_name, tab_name); | ||
ELSE | ||
SELECT COUNT(*) INTO table_count FROM pg_catalog.pg_class WHERE relkind = 'r' AND relnamespace = sch_id; | ||
fq_table_name := format('%I.%I', schema_name, 'Table ' || (table_count + 1)); |
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.
Correct me if I'm wrong, but I think there may be a bug here. Say I begin with zero tables...
- I create a table. It gets named
Table 1
. - I create another table. It gets named
Table 2
. - I delete the first table.
- I create a third table. Within this function
table_count
will be1
sofq_table_name
will be something likepublic."Table 2"
. Butpublic."Table 2"
already exists soCREATE TABLE
will fail.
Right?
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.
You are correct @seancolsen, I've fixed the bug and added a test in 0450fbe, thanks for catching it!
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.
Cool. I haven't reviewed thoroughly, but your changes look good from a glance. I'll leave it to Brent to review fully.
Fixes #3636
Replicates the current behaviour our table add REST endpoint and generate table name if one isn't provided.
Checklist
Update index.md
).develop
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin