pg_json 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/pg_json +12 -34
- metadata +1 -1
data/bin/pg_json
CHANGED
@@ -20,40 +20,6 @@ $$ language plpgsql;
|
|
20
20
|
array(type)
|
21
21
|
end
|
22
22
|
|
23
|
-
simple :integer
|
24
|
-
simple :float
|
25
|
-
simple :text do
|
26
|
-
"'\"'||data::text||'\"'"
|
27
|
-
end
|
28
|
-
simple :date do
|
29
|
-
"'\"'||to_char(data, 'YYYY-MM-DD')::text||'\"'"
|
30
|
-
end
|
31
|
-
simple :time do
|
32
|
-
"'\"'||to_char(data, 'HH24:MI:SS')::text||'\"'"
|
33
|
-
end
|
34
|
-
|
35
|
-
# def unquoted(type)
|
36
|
-
# puts <<-EOF
|
37
|
-
# create or replace function to_json(data #{type}) returns text as $$
|
38
|
-
# begin
|
39
|
-
# return (case when data is null then 'null' else data::text end);
|
40
|
-
# end;
|
41
|
-
# $$ language plpgsql;
|
42
|
-
# EOF
|
43
|
-
# array(type)
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# def quoted(type)
|
47
|
-
# puts <<-EOF
|
48
|
-
# create or replace function to_json(data #{type}) returns text as $$
|
49
|
-
# begin
|
50
|
-
# return (case when data is null then 'null' else '"'||data::text||'"' end);
|
51
|
-
# end;
|
52
|
-
# $$ language plpgsql;
|
53
|
-
# EOF
|
54
|
-
# array(type)
|
55
|
-
# end
|
56
|
-
|
57
23
|
def composite(type)
|
58
24
|
sql = <<-SQL
|
59
25
|
select t1.name from (
|
@@ -108,6 +74,18 @@ $$ language plpgsql;
|
|
108
74
|
EOF
|
109
75
|
end
|
110
76
|
|
77
|
+
simple :integer
|
78
|
+
simple :float
|
79
|
+
simple :text do
|
80
|
+
"'\"'||data::text||'\"'"
|
81
|
+
end
|
82
|
+
simple :date do
|
83
|
+
"'\"'||to_char(data, 'YYYY-MM-DD')::text||'\"'"
|
84
|
+
end
|
85
|
+
simple :time do
|
86
|
+
"'\"'||to_char(data, 'HH24:MI:SS')::text||'\"'"
|
87
|
+
end
|
88
|
+
|
111
89
|
while composite = ARGV.slice!(0)
|
112
90
|
send :composite, composite.to_sym
|
113
91
|
end
|