-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathquery.sql
27 lines (22 loc) · 983 Bytes
/
query.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- name: FindAllDevices :many
SELECT mac, type
FROM device;
-- name: InsertDevice :exec
INSERT INTO device (mac, type)
VALUES (pggen.arg('Mac'), pggen.arg('TypePg'));
-- Select an array of all device_type enum values.
-- name: FindOneDeviceArray :one
SELECT enum_range(NULL::device_type) AS device_types;
-- Select many rows of device_type enum values.
-- name: FindManyDeviceArray :many
SELECT enum_range('ipad'::device_type, 'iot'::device_type) AS device_types
UNION ALL
SELECT enum_range(NULL::device_type) AS device_types;
-- Select many rows of device_type enum values with multiple output columns.
-- name: FindManyDeviceArrayWithNum :many
SELECT 1 AS num, enum_range('ipad'::device_type, 'iot'::device_type) AS device_types
UNION ALL
SELECT 2 as num, enum_range(NULL::device_type) AS device_types;
-- Regression test for https://github.com/jschaf/pggen/issues/23.
-- name: EnumInsideComposite :one
SELECT ROW('08:00:2b:01:02:03'::macaddr, 'phone'::device_type) ::device;