piccolo icon indicating copy to clipboard operation
piccolo copied to clipboard

Column types unknown to Piccolo crash schema generation in default look-up.

Open gmos opened this issue 4 years ago • 2 comments

Piccolo doesn't handle the (fixed length) Character datatype.
When the column type is unknown to Piccolo, the schema generation defaults to the generic Column type, and a warning is added to the output.

Later on the generator attempts to parse the default value for the column. Unfortunately the COLUMN_DEFAULT_PARSER map does not contain an entry for Column, causing the generation to fail with a key-error.

Solution is to use a get(). Near line 358: pat = COLUMN_DEFAULT_PARSER.get(column_type)

Same is true for the Array datatype which is also currently not handled by Piccolo.

gmos avatar Nov 29 '21 16:11 gmos

@gmos You're right - good catch.

I'm surprised the unit tests didn't catch this, I need to investigate.

I've opened a PR which makes the change you suggested.

It would be fairly simple to add a Character column type to Piccolo. I don't tend to use them - what kinds of things do you usually use them for?

dantownsend avatar Nov 29 '21 20:11 dantownsend

@dantownsend I use Character type for fixed length ID's of sensors. Saves one (or two) length bytes per item. Is a wee bit more economical on storage, memory and CPU and comparisons, sorts etc will be bit faster. Actually irrelevant for my application with only 1000 or so sensors. More a habit from long ago. I'll happily change them to varchar in the DB.

But the absence of Array can't be worked around. Not having a crash anymore is ok for now. Support for arrays would be nice, but I have it only once.

gmos avatar Nov 30 '21 00:11 gmos