Skip to content
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

Reference: Types #87

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Reference: Types #87

wants to merge 4 commits into from

Conversation

janpio
Copy link
Member

@janpio janpio commented Feb 12, 2020

We need databases that have all the types possible in MySQL, Postgres and SQLite. This PR adds a new database reference that has a types table that has an @id (ID int(11) auto increment as Primary Key) and one column per possible type.

Source for types:


For MySQL the columns are roughly named and sorted by the structure of the reference documentation, so the name is enough to recognize the original type.

The type "parameter" (e.g. 255 for VARCHAR) is e.g. the default, if you create the column without setting a value or a reasonable enough manually chosen value.


MySQL types table in phpMyAdmin:
image

@matthewmueller

This comment has been minimized.

@janpio janpio added the SQLite label Feb 14, 2020
@janpio janpio modified the milestones: Preview 22, Preview 23 Feb 18, 2020
@janpio
Copy link
Member Author

janpio commented Feb 25, 2020

A more elaborate version of what Matt built, with all columns named by the type they have:

create table crazy2 (
	numeric_integer_smallint smallint,
	numeric_integer_integer integer,
	numeric_integer_bigint bigint,
	numeric_integer_decimal decimal,
	numeric_arbitrary_numeric numeric,
	numeric_floating_real real,
	numeric_floating_double_precision double precision,
	numeric_serial_smallserial smallserial,
	numeric_serial_serial serial,
	numeric_serial_bigserial bigserial,
	monetary_money money,
	character_character_varying character varying,
	character_character character,
	character_varchar varchar,
	character_char char,
	character_text text,
	binary_bytea bytea,
	datetime_timestamp timestamp,
	datetime_timestamp_without_time_zone timestamp without time zone,
	datetime_timestamp_with_time_zone timestamp with time zone,
	datetime_timestamptz timestamptz,
	datetime_date date,
	datetime_time time,
	datetime_time_without_time_zone time without time zone,
	datetime_time_with_time_zone time with time zone,
	datetime_interval interval,
	datetime_interval_year interval year,
	datetime_interval_month interval month,
	datetime_interval_day interval day,
	datetime_interval_hour interval hour,
	datetime_interval_minute interval minute,
	datetime_interval_second interval second,
	datetime_interval_year_to_month interval year to month,
	datetime_interval_day_to_hour interval day to hour,
	datetime_interval_day_to_minute interval day to minute,
	datetime_interval_day_to_second interval day to second,
	datetime_interval_hour_to_minute interval hour to minute,
	datetime_interval_hour_to_second interval hour to second,
	datetime_interval_minute_to_second interval minute to second,
	boolean_boolean boolean,
	geometric_point point,
	geometric_line line,
	geometric_lseg lseg,
	geometric_box box,
	geometric_path path,
	geometric_polygon polygon,
	geometric_circle circle,
	network_cidr cidr,
	network_inet inet,
	network_macaddr macaddr,
	network_macaddr8 macaddr8,
	bitstring_bit bit,
	bitstring_bit_varying bit varying,
	textsearch_tsvector tsvector,
	textsearch_tsquery tsquery,
	uuid_uuid uuid,
	xml_xml xml,
	json_json json,
	json_jsonb jsonb,
	range_int4range int4range,
	range_int8range int8range,
	range_numrange numrange,
	range_tsrange tsrange,
	range_tstzrange tstzrange,
	range_daterange daterange,
	other_pg_lsn pg_lsn,
	other_txid_snapshot txid_snapshot
)
create table crazy3 (
	numeric_integer_smallint smallint[],
	numeric_integer_integer integer[],
	numeric_integer_bigint bigint[],
	numeric_integer_decimal decimal[],
	numeric_arbitrary_numeric numeric[],
	numeric_floating_real real[],
	numeric_floating_double_precision double precision[],
	monetary_money money[],
	character_character_varying character varying[],
	character_character character[],
	character_varchar varchar[],
	character_char char[],
	character_text text[],
	binary_bytea bytea[],
	datetime_timestamp timestamp[],
	datetime_timestamp_without_time_zone timestamp without time zone[],
	datetime_timestamp_with_time_zone timestamp with time zone[],
	datetime_timestamptz timestamptz[],
	datetime_date date[],
	datetime_time time[],
	datetime_time_without_time_zone time without time zone[],
	datetime_time_with_time_zone time with time zone[],
	datetime_interval interval[],
	datetime_interval_year interval year[],
	datetime_interval_month interval month[],
	datetime_interval_day interval day[],
	datetime_interval_hour interval hour[],
	datetime_interval_minute interval minute[],
	datetime_interval_second interval second[],
	datetime_interval_year_to_month interval year to month[],
	datetime_interval_day_to_hour interval day to hour[],
	datetime_interval_day_to_minute interval day to minute[],
	datetime_interval_day_to_second interval day to second[],
	datetime_interval_hour_to_minute interval hour to minute[],
	datetime_interval_hour_to_second interval hour to second[],
	datetime_interval_minute_to_second interval minute to second[],
	boolean_boolean boolean[],
	geometric_point point[],
	geometric_line line[],
	geometric_lseg lseg[],
	geometric_box box[],
	geometric_path path[],
	geometric_polygon polygon[],
	geometric_circle circle[],
	network_cidr cidr[],
	network_inet inet[],
	network_macaddr macaddr[],
	network_macaddr8 macaddr8[],
	bitstring_bit bit[],
	bitstring_bit_varying bit varying[],
	textsearch_tsvector tsvector[],
	textsearch_tsquery tsquery[],
	uuid_uuid uuid[],
	xml_xml xml[],
	json_json json[],
	json_jsonb jsonb[],
	range_int4range int4range[],
	range_int8range int8range[],
	range_numrange numrange[],
	range_tsrange tsrange[],
	range_tstzrange tstzrange[],
	range_daterange daterange[],
	other_pg_lsn pg_lsn[],
	other_txid_snapshot txid_snapshot[]
)

@matthewmueller
Copy link
Contributor

Not sure if this is intentional or not, but one thing to note here is that I think it's important to test types like numeric [ (p, s) ]. Your revised tables are missing valid variations.

@matthewmueller
Copy link
Contributor

Data Type Alias Description
bigint int8 signed eight-byte integer
bigserial serial8 autoincrementing eight-byte integer
bit [ (n) ] fixed-length bit string
bit varying [ (n) ] varbit [ (n) ] variable-length bit string
boolean bool logical Boolean (true/false)
box rectangular box on a plane
bytea binary data ("byte array")
character [ (n) ] char [ (n) ] fixed-length character string
character varying [ (n) ] varchar [ (n) ] variable-length character string
cidr IPv4 or IPv6 network address
circle circle on a plane
date calendar date (year, month, day)
double precision float8 double precision floating-point number (8 bytes)
inet IPv4 or IPv6 host address
integer int, int4 signed four-byte integer
interval [ fields ][ (p) ] time span
json textual JSON data
jsonb binary JSON data, decomposed
line infinite line on a plane
lseg line segment on a plane
macaddr MAC (Media Access Control) address
money currency amount
numeric [ (p, s) ] decimal [ (p, s) ] exact numeric of selectable precision
path geometric path on a plane
pg_lsn PostgreSQL Log Sequence Number
point geometric point on a plane
polygon closed geometric path on a plane
real float4 single precision floating-point number (4 bytes)
smallint int2 signed two-byte integer
smallserial serial2 autoincrementing two-byte integer
serial serial4 autoincrementing four-byte integer
text variable-length character string
time [ (p) ][ without time zone ] time of day (no time zone)
time [ (p) ] with time zone timetz time of day, including time zone
timestamp [ (p) ][ without time zone ] date and time (no time zone)
timestamp [ (p) ] with time zone timestamptz date and time, including time zone
tsquery text search query
tsvector text search document
txid_snapshot user-level transaction ID snapshot
uuid universally unique identifier
xml XML data

@janpio
Copy link
Member Author

janpio commented Mar 10, 2020

Not sure if this is intentional or not, but one thing to note here is that I think it's important to test types like numeric [ (p, s) ]. Your revised tables are missing valid variations.

How so? numeric_arbitrary_numeric numeric is present and defaults to some value for (p, s) I assume?

@divyenduz divyenduz modified the milestones: Preview 24 Old, Preview 25 Mar 13, 2020
@matthewmueller
Copy link
Contributor

matthewmueller commented Mar 26, 2020

You probably want something like:

numeric_arbitrary_numeric numeric,
numeric_arbitrary_numeric2 numeric(7, 1),
numeric_arbitrary_numeric3 numeric(2, 7)

Some variety to ensure that introspection can also handle explicit parameters.

@janpio janpio changed the base branch from master to main September 29, 2020 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants