kaui 0.16.0 → 0.16.1
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.
- checksums.yaml +4 -4
- data/lib/kaui.rb +0 -4
- data/lib/kaui/version.rb +1 -1
- metadata +2 -3
- data/lib/core_ext.rb +0 -191
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 449f2c696715c4edfe153735029a7d17dbdab1af
|
4
|
+
data.tar.gz: 9452c3e8081ccb8f147b78d16f6d1cb0ef100c08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9df400134d15cc3eb08ccd125b24eb15ff83cdd1fbfa52b352a19ff9e6c3e934bb213b34cabcfa240d386bd33b4a8c22d91101ae32d466a002c6cd81a182d784
|
7
|
+
data.tar.gz: cc1d8e01bf3ffd7a022605a652f075f06767301edf8d459ab90e4fbce56f8fe666ffd20f2abef14bfb1c9d7adab952760dbab9b484e3389182ccea1e6b5887f2
|
data/lib/kaui.rb
CHANGED
data/lib/kaui/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Killbill core team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -709,7 +709,6 @@ files:
|
|
709
709
|
- db/migrate/20150109214021_create_kaui_tenants.rb
|
710
710
|
- db/migrate/20150112232813_create_kaui_allowed_users.rb
|
711
711
|
- db/schema.rb
|
712
|
-
- lib/core_ext.rb
|
713
712
|
- lib/generators/kaui/install/install_generator.rb
|
714
713
|
- lib/generators/kaui/install/templates/config/initializers/kaui.rb
|
715
714
|
- lib/kaui.rb
|
data/lib/core_ext.rb
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
# https://github.com/jruby/activerecord-jdbc-adapter/issues/780
|
2
|
-
# https://github.com/rails/rails/commit/ae39b1a03d0a859be9d5342592c8936f89fcbacf
|
3
|
-
|
4
|
-
require 'arjdbc'
|
5
|
-
require 'arjdbc/mysql/adapter.rb'
|
6
|
-
require 'arjdbc/mysql/schema_creation.rb'
|
7
|
-
|
8
|
-
module ArJdbc
|
9
|
-
module MySQL
|
10
|
-
|
11
|
-
if defined? ::ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation
|
12
|
-
class SchemaCreation < ::ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation
|
13
|
-
|
14
|
-
def visit_ChangeColumnDefinition(o)
|
15
|
-
column = o.column
|
16
|
-
options = o.options
|
17
|
-
sql_type = type_to_sql(o.type, options)
|
18
|
-
change_column_sql = "CHANGE #{quote_column_name(column.name)} #{quote_column_name(options[:name])} #{sql_type}"
|
19
|
-
add_column_options!(change_column_sql, options.merge(:column => column))
|
20
|
-
add_column_position!(change_column_sql, options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def column_options(o)
|
24
|
-
super
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# @override
|
29
|
-
def add_column(table_name, column_name, type, options = {})
|
30
|
-
add_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options)}"
|
31
|
-
add_column_options!(add_column_sql, options)
|
32
|
-
add_column_position!(add_column_sql, options)
|
33
|
-
execute(add_column_sql)
|
34
|
-
end unless const_defined? :SchemaCreation
|
35
|
-
|
36
|
-
# @override
|
37
|
-
def change_column(table_name, column_name, type, options = {})
|
38
|
-
column = column_for(table_name, column_name)
|
39
|
-
|
40
|
-
unless options_include_default?(options)
|
41
|
-
# NOTE: no defaults for BLOB/TEXT columns with MySQL
|
42
|
-
options[:default] = column.default if type != :text && type != :binary
|
43
|
-
end
|
44
|
-
|
45
|
-
unless options.has_key?(:null)
|
46
|
-
options[:null] = column.null
|
47
|
-
end
|
48
|
-
|
49
|
-
change_column_sql = "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(column_name)} #{type_to_sql(type, options)}"
|
50
|
-
add_column_options!(change_column_sql, options)
|
51
|
-
add_column_position!(change_column_sql, options)
|
52
|
-
execute(change_column_sql)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Maps logical Rails types to MySQL-specific data types.
|
56
|
-
def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
|
57
|
-
case type.to_s
|
58
|
-
when 'binary'
|
59
|
-
case limit
|
60
|
-
when 0..0xfff; "varbinary(#{limit})"
|
61
|
-
when nil; "blob"
|
62
|
-
when 0x1000..0xffffffff; "blob(#{limit})"
|
63
|
-
else raise(ActiveRecordError, "No binary type has character length #{limit}")
|
64
|
-
end
|
65
|
-
when 'integer'
|
66
|
-
case limit
|
67
|
-
when 1; 'tinyint'
|
68
|
-
when 2; 'smallint'
|
69
|
-
when 3; 'mediumint'
|
70
|
-
when nil, 4, 11; 'int(11)' # compatibility with MySQL default
|
71
|
-
when 5..8; 'bigint'
|
72
|
-
else raise(ActiveRecordError, "No integer type has byte size #{limit}")
|
73
|
-
end
|
74
|
-
when 'text'
|
75
|
-
case limit
|
76
|
-
when 0..0xff; 'tinytext'
|
77
|
-
when nil, 0x100..0xffff; 'text'
|
78
|
-
when 0x10000..0xffffff; 'mediumtext'
|
79
|
-
when 0x1000000..0xffffffff; 'longtext'
|
80
|
-
else raise(ActiveRecordError, "No text type has character length #{limit}")
|
81
|
-
end
|
82
|
-
when 'datetime'
|
83
|
-
return super unless precision
|
84
|
-
|
85
|
-
case precision
|
86
|
-
when 0..6; "datetime(#{precision})"
|
87
|
-
else raise(ActiveRecordError, "No datetime type has precision of #{precision}. The allowed range of precision is from 0 to 6.")
|
88
|
-
end
|
89
|
-
else
|
90
|
-
super
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def prepare_column_options(column)
|
96
|
-
spec = super
|
97
|
-
spec.delete(:limit) if column.type == :boolean
|
98
|
-
spec
|
99
|
-
end
|
100
|
-
|
101
|
-
def translate_exception(exception, message)
|
102
|
-
return super unless exception.respond_to?(:errno)
|
103
|
-
|
104
|
-
case exception.errno
|
105
|
-
when 1062
|
106
|
-
::ActiveRecord::RecordNotUnique.new(message)
|
107
|
-
when 1452
|
108
|
-
::ActiveRecord::InvalidForeignKey.new(message)
|
109
|
-
else
|
110
|
-
super
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
if defined?(JRUBY_VERSION)
|
117
|
-
require 'active_record/connection_adapters/postgresql/schema_definitions'
|
118
|
-
class ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnDefinition < ActiveRecord::ConnectionAdapters::ColumnDefinition
|
119
|
-
attr_accessor :array
|
120
|
-
end
|
121
|
-
|
122
|
-
require 'active_record/connection_adapters/postgresql/database_statements'
|
123
|
-
module ActiveRecord
|
124
|
-
module ConnectionAdapters
|
125
|
-
module PostgreSQL
|
126
|
-
module DatabaseStatements
|
127
|
-
def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)
|
128
|
-
if use_insert_returning? || pk == false
|
129
|
-
super
|
130
|
-
else
|
131
|
-
result = exec_update(sql, name, binds)
|
132
|
-
unless sequence_name
|
133
|
-
table_ref = extract_table_ref_from_insert_sql(sql)
|
134
|
-
if table_ref
|
135
|
-
pk = primary_key(table_ref) if pk.nil?
|
136
|
-
pk = suppress_composite_primary_key(pk)
|
137
|
-
sequence_name = default_sequence_name(table_ref, pk)
|
138
|
-
end
|
139
|
-
return result unless sequence_name
|
140
|
-
end
|
141
|
-
last_insert_id_result(sequence_name)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
module ArJdbc
|
151
|
-
module PostgreSQL
|
152
|
-
|
153
|
-
# Returns the list of all column definitions for a table.
|
154
|
-
def columns(table_name, name = nil)
|
155
|
-
column = jdbc_column_class
|
156
|
-
column_definitions(table_name).map! do |row|
|
157
|
-
# |name, type, default, notnull, oid, fmod|
|
158
|
-
name = row[0]; type = row[1]; default = row[2]
|
159
|
-
notnull = row[3]; oid = row[4]; fmod = row[5]
|
160
|
-
# oid = OID::TYPE_MAP.fetch(oid.to_i, fmod.to_i) { OID::Identity.new }
|
161
|
-
notnull = notnull == 't' if notnull.is_a?(String) # JDBC gets true/false
|
162
|
-
# for ID columns we get a bit of non-sense default :
|
163
|
-
# e.g. "nextval('mixed_cases_id_seq'::regclass"
|
164
|
-
if default =~ /^nextval\(.*?\:\:regclass\)$/
|
165
|
-
default = nil
|
166
|
-
elsif default =~ /^\(([-+]?[\d\.]+)\)$/ # e.g. "(-1)" for a negative default
|
167
|
-
default = $1
|
168
|
-
end
|
169
|
-
|
170
|
-
collation = row[6]
|
171
|
-
comment = row[7]
|
172
|
-
|
173
|
-
type_metadata = fetch_type_metadata(name, type, oid.to_i, fmod.to_i)
|
174
|
-
|
175
|
-
column.new(name, default, type_metadata, !notnull, table_name, nil, collation, comment: comment.presence)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
def fetch_type_metadata(column_name, sql_type, oid, fmod)
|
180
|
-
cast_type = get_oid_type(oid, fmod, column_name, sql_type)
|
181
|
-
simple_type = ::ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(
|
182
|
-
sql_type: sql_type,
|
183
|
-
type: cast_type.type,
|
184
|
-
limit: cast_type.limit,
|
185
|
-
precision: cast_type.precision,
|
186
|
-
scale: cast_type.scale,
|
187
|
-
)
|
188
|
-
::ActiveRecord::ConnectionAdapters::PostgreSQLTypeMetadata.new(simple_type, oid: oid, fmod: fmod)
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|