-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sql
More file actions
42 lines (32 loc) · 886 Bytes
/
Copy pathtest.sql
File metadata and controls
42 lines (32 loc) · 886 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- Test pg_zerialize extension
-- Drop extension if it exists
DROP EXTENSION IF EXISTS pg_zerialize CASCADE;
-- Create the extension
CREATE EXTENSION pg_zerialize;
-- Test 1: Simple row with mixed types
SELECT row_to_flexbuffers(ROW('Alice', 30, true)::record);
-- Test 2: Named record type
CREATE TYPE person AS (
name text,
age int,
active boolean,
salary float8
);
SELECT row_to_flexbuffers(ROW('Bob', 25, false, 75000.50)::person);
-- Test 3: NULL values
SELECT row_to_flexbuffers(ROW('Charlie', NULL, true)::record);
-- Test 4: From table data
CREATE TABLE users (
id serial PRIMARY KEY,
username text NOT NULL,
age int,
score float8
);
INSERT INTO users (username, age, score) VALUES
('user1', 25, 95.5),
('user2', 30, 87.3);
SELECT username, row_to_flexbuffers(users.*)
FROM users;
-- Cleanup
DROP TABLE users;
DROP TYPE person;