-
Notifications
You must be signed in to change notification settings - Fork 53
Add support to detect string cartodb_id columns #202
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
Conversation
| RAISE DEBUG 'CDB(_CDB_Has_Usable_Primary_ID): Found text column %', rec.atttypid; | ||
|
|
||
| BEGIN | ||
| sql := Format('ALTER TABLE %s ALTER cartodb_id TYPE int USING %I::integer', reloid::text, rec.attname); |
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.
better noting this is traversing the table and therefore breaking the paradigm of the "rewrite" function: just do one pass after figuring it out how to transform into the intended target table.
|
Related disabled tests: cartodb-postgresql/test/CDB_CartodbfyTableTest.sql Lines 167 to 179 in 54973c0
|
|
you can blame me :S and re-enable those tests |
|
Not blaming! text was not supported anymore so... :) I reenabled and added an extra one for text column in an empty table, I'm still playing with it locally. |
| DO $$ | ||
| BEGIN | ||
| IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = '_cdb_has_usable_primary_id_record') THEN | ||
| CREATE TYPE _cdb_has_usable_primary_id_record |
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.
I would use types sparingly. Alternatively the function can return a RECORD
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.
Agree :-) I had some issues late yesterday with the returns and one of my attempts was to force this, but it's not needed anymore.
|
So:
|
|
Okay, if I didn't miss anything again, this is now more aligned. I didn't edit at all the branch of "if there's another valid column not named cartodb_id..." as we said and as I wrote in my last comment. |
test/CDB_CartodbfyTableTest_expect
Outdated
| 5 | ||
| DROP TABLE | ||
| SELECT 1 | ||
| ERROR: CDB(_CDB_Rewrite_Table:22P02:invalid input syntax for integer: "nan"): CREATE TABLE public.t_0 AS SELECT cartodb_id::bigint ,NULL::geometry(Geometry,4326) AS the_geom,NULL::geometry(Geometry,3857) AS the_geom_webmercator FROM t |
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.
Wondering if I could make the CartoDBfy test function to catch these errors and output a less verbose error instead of performing tests against this specific context backtrace.
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.
Answering to myself: I set verbosity to terse to avoid contexts.
|
👍 time to prepare a release |
|
From @rafatower's feedback, add test:
|
|
Some inconsistency here: Scenario A: CartoDBfication works, result: Scenario B: CartoDBfication fails: Both cases are out of the requirements (integer -- or casteable-- and unique), but both have different outcomes (silent rename VS crash 💥) |
|
The new commit makes failures consistent: everything will just crash now. I've updated the tests too, so as soon as I fix the Rails part to give good feedback about the failure we're good. |
|
Tests passing :-) @rafatower could you give this a look again? |
|
👍 |
| i INTEGER; | ||
| sql TEXT; | ||
| useable_key BOOLEAN = false; | ||
| has_usable_primary_key BOOLEAN = false; |
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.
Unused variable.
|
My tests in staging are going on here: https://gist.github.com/iriberri/d839f6e67e05c6454a1d |
Add support to detect string cartodb_id columns
Going to try adding more tests now.