For a sample API resource like so:
res = schema.Schema {
Fields: schema.Fields {
"id": schema.IDField,
"bool_field": {
Validator: &schema.Bool{},
},
}
Note that when Create is called on the handler, the table will be created (using BIT(1) rather than BOOLEAN).
When inserting into a field of BOOLEAN type, PostgreSQL will automatically convert the strings 'true' and 'false' (case-insensitive, and all prefixes will work), and the complete unquoted words.
BIT(1) does not automatically type convert on insertion; any API request populating the example bool_field will trigger an error.
Sample PostgreSQL logs:
2019-05-07 15:01:56.969 EDT [207883] STATEMENT: INSERT INTO status (etag,id,bool_field) VALUES ($1,$2,$3)
2019-05-07 15:02:32.059 EDT [208162] ERROR: "t" is not a valid binary digit
For a sample API resource like so:
Note that when Create is called on the handler, the table will be created (using BIT(1) rather than BOOLEAN).
When inserting into a field of BOOLEAN type, PostgreSQL will automatically convert the strings 'true' and 'false' (case-insensitive, and all prefixes will work), and the complete unquoted words.
BIT(1) does not automatically type convert on insertion; any API request populating the example bool_field will trigger an error.
Sample PostgreSQL logs: