rgviz-rails 0.19 → 0.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,68 @@
1
+ module Rgviz
2
+ class PostgreSqlAdapter
3
+ def accept_scalar_function_column(node, visitor)
4
+ case node.function
5
+ when ScalarFunctionColumn::Year
6
+ visitor << "date_part('year',"
7
+ node.arguments[0].accept visitor
8
+ visitor << ")"
9
+ when ScalarFunctionColumn::Month
10
+ visitor << "date_part('month',"
11
+ node.arguments[0].accept visitor
12
+ visitor << ")"
13
+ when ScalarFunctionColumn::Day
14
+ visitor << "date_part('day',"
15
+ node.arguments[0].accept visitor
16
+ visitor << ")"
17
+ when ScalarFunctionColumn::Hour
18
+ visitor << "date_part('hour',"
19
+ node.arguments[0].accept visitor
20
+ visitor << ")"
21
+ when ScalarFunctionColumn::Minute
22
+ visitor << "date_part('minute',"
23
+ node.arguments[0].accept visitor
24
+ visitor << ")"
25
+ when ScalarFunctionColumn::Second
26
+ visitor << "date_part('second',"
27
+ node.arguments[0].accept visitor
28
+ visitor << ")"
29
+ when ScalarFunctionColumn::Millisecond
30
+ visitor << "date_part('milliseconds',"
31
+ node.arguments[0].accept visitor
32
+ visitor << ")"
33
+ when ScalarFunctionColumn::Quarter
34
+ visitor << "date_part('quarter',"
35
+ node.arguments[0].accept visitor
36
+ visitor << ")"
37
+ when ScalarFunctionColumn::DayOfWeek
38
+ visitor << "1 + date_part('dow',"
39
+ node.arguments[0].accept visitor
40
+ visitor << ")"
41
+ when ScalarFunctionColumn::Now
42
+ visitor << "now()"
43
+ when ScalarFunctionColumn::DateDiff
44
+ visitor << "(date "
45
+ node.arguments[0].accept visitor
46
+ visitor << " - date "
47
+ node.arguments[1].accept visitor
48
+ visitor << ")"
49
+ when ScalarFunctionColumn::ToDate
50
+ visitor << "to_char("
51
+ arg = node.arguments[0]
52
+ if arg.kind_of?(StringColumn) || arg.kind_of?(DateColumn) || arg.kind_of?(DateTimeColumn) || arg.kind_of?(TimeOfDayColumn)
53
+ visitor << "date "
54
+ end
55
+ arg.accept visitor
56
+ visitor << ", 'yyyy-mm-dd')"
57
+ when ScalarFunctionColumn::Upper
58
+ visitor << "upper("
59
+ node.arguments[0].accept visitor
60
+ visitor << ")"
61
+ when ScalarFunctionColumn::Lower
62
+ visitor << "lower("
63
+ node.arguments[0].accept visitor
64
+ visitor << ")"
65
+ end
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgviz-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 45
4
+ hash: 35
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 19
9
- version: "0.19"
8
+ - 20
9
+ version: "0.20"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ary Borenszweig
@@ -30,6 +30,7 @@ files:
30
30
  - lib/rgviz_rails.rb
31
31
  - lib/rgviz_rails/executor.rb
32
32
  - lib/rgviz_rails/adapters/mysql_adapter.rb
33
+ - lib/rgviz_rails/adapters/postgresql_adapter.rb
33
34
  - lib/rgviz_rails/adapters/sqlite_adapter.rb
34
35
  - rails/init.rb
35
36
  - spec/blueprints.rb