-
Notifications
You must be signed in to change notification settings - Fork 40
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
Expand use of QualifiedName
to types, composites, enums
#263
Conversation
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
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.
LGTM!
, typeName = | ||
TypeName | ||
{ name = "bpchar" | ||
, modifiers = ["1"] | ||
, arrayDepth = 0 | ||
} |
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.
Any reason to not just stay with char
?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
'stypeName
toQualifiedName
, 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 anIsString
instance, so the common case (schema
set toNothing
, no modifiers, scalar type) will continue working as before.