Expand use of QualifiedName to types, composites, enums#263
Expand use of QualifiedName to types, composites, enums#263shane-circuithub merged 1 commit intomasterfrom
QualifiedName to types, composites, enums#263Conversation
QualifiedName to types, composites, enums
Types in PostgreSQL can also be qualified with a schema. However, it's not sufficient to just change the type of `TypeInformation`'s `typeName` to `QualifiedName`, because a type isn't *just* a name. Postgres types can also be parameterised by modifiers (e.g., `numeric(7, 2)`) and array types of arbitrary depth (e.g., `int4[][]`). To accomodate this, a new type is introduced, `TypeName`. Like `QualifiedName`, it has an `IsString` instance, so the common case (`schema` set to `Nothing`, no modifiers, scalar type) will continue working as before.
4ccbc5a to
f4237aa
Compare
| , typeName = | ||
| TypeName | ||
| { name = "bpchar" | ||
| , modifiers = ["1"] | ||
| , arrayDepth = 0 | ||
| } |
There was a problem hiding this comment.
Any reason to not just stay with char?
There was a problem hiding this comment.
Because the underlying type is actually called bpchar, not char. Now that we quote things properly, the SQL we produce for lit '👍' will be '👍'::"char". However, in PostgreSQL, char and "char" are different types, with the former meaning bpchar latter meaning a single ASCII character, so if we don't change this to bpchar then lit '👍' == lit '👎'.
| - `TypeInformation`'s `typeName` parameter from `String` to `TypeName`. | ||
| - `DBEnum`'s `enumTypeName` method from `String` to `QualifiedName`. | ||
| - `DBComposite`'s `compositeTypeName` method from `String` to `QualifiedName`. |
There was a problem hiding this comment.
Assuming this is true:
| - `TypeInformation`'s `typeName` parameter from `String` to `TypeName`. | |
| - `DBEnum`'s `enumTypeName` method from `String` to `QualifiedName`. | |
| - `DBComposite`'s `compositeTypeName` method from `String` to `QualifiedName`. | |
| - `TypeInformation`'s `typeName` parameter from `String` to `TypeName`. | |
| - `DBEnum`'s `enumTypeName` method from `String` to `QualifiedName`. | |
| - `DBComposite`'s `compositeTypeName` method from `String` to `QualifiedName`. | |
| - Both `TypeName` and `QualifiedName` have `IsString` instances which have the same behavior as the original `String` types they now replace. |
There was a problem hiding this comment.
Eh, kind of. If your string represents an unqualified name with no uppercase or special characters (or modifiers or array nonsense in the case of TypeName), then yes. Otherwise, no. Someone could previously have set typeName to a String like "\"mySchema\".\"myType\"(4)[][]" — we make no attempt to parse that into a TypeName.
Types in PostgreSQL can also be qualified with a schema. However, it's not sufficient to just change the type of
TypeInformation'stypeNametoQualifiedName, because a type isn't just a name. Postgres types can also be parameterised by modifiers (e.g.,numeric(7, 2)) and array types of arbitrary depth (e.g.,int4[][]).To accomodate this, a new type is introduced,
TypeName. LikeQualifiedName, it has anIsStringinstance, so the common case (schemaset toNothing, no modifiers, scalar type) will continue working as before.