active-dbml 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active/dbml/version.rb +1 -1
- data/lib/active/dbml.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12bd9ed40bdbfe316aae38c4f1621973400d962673037489fdfe6364ee43ce1a
|
4
|
+
data.tar.gz: bf287cb8da032c1bee1f9679a4179775f520f63b4ba358b014784ffb5c00f0a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 524482569e3c543781212a64897f63a1bd92287345aeb9272042f48bc9a58f76d83fac9d11a860128613e58eadd9c2d20859a4ac9a75911789f26d8cf696d53f
|
7
|
+
data.tar.gz: 27ca499cb33ecd107507dec7fbaa75a1685381770aabef67aa8332e1bf8b9dc73ae4abc8541a309312312f2673ffc091d4a233c3a0915f8928d6ffaba9d39450
|
data/lib/active/dbml/version.rb
CHANGED
data/lib/active/dbml.rb
CHANGED
@@ -63,14 +63,14 @@ module Active
|
|
63
63
|
# get foreign key only belongs_to association
|
64
64
|
model.reflect_on_all_associations(:belongs_to).each do |association|
|
65
65
|
begin
|
66
|
+
foreign_key = association.foreign_key
|
67
|
+
foreign_key_destination = "#{association.plural_name}.#{association.class_name.constantize.primary_key}"
|
68
|
+
|
66
69
|
# NOTE: Check model type
|
67
70
|
# Skip anything other than ActiveRecord::Base
|
68
71
|
if association.class_name.constantize < ActiveRecord::Base
|
69
72
|
association.class_name.constantize.reflect_on_all_associations.each do |relation_association|
|
70
73
|
if model.table_name.eql?(relation_association.plural_name)
|
71
|
-
foreign_key = association.options[:foreign_key]
|
72
|
-
foreign_key_destination = "#{association.plural_name}.#{association.class_name.constantize.primary_key}"
|
73
|
-
|
74
74
|
case relation_association.macro
|
75
75
|
when :has_one
|
76
76
|
foreign_keys[foreign_key] = { destination: foreign_key_destination, relation_type: '-' }
|
@@ -100,6 +100,7 @@ module Active
|
|
100
100
|
options = []
|
101
101
|
options.push 'pk' if primary_key.eql?(column.name)
|
102
102
|
options.push 'not null' if !column.null
|
103
|
+
options.push "default: '#{column.default}'" if column.default
|
103
104
|
options.push "note: '#{column.comment}'" if column.comment.present?
|
104
105
|
options.push "ref: #{foreign_keys[column.name][:relation_type]} #{foreign_keys[column.name][:destination]}" if foreign_keys.key?(column.name)
|
105
106
|
|
@@ -135,7 +136,8 @@ module Active
|
|
135
136
|
if key.present? && !enums_generated.include?(key)
|
136
137
|
dbml_output << "Enum #{key} {"
|
137
138
|
value.keys.each do |value_key|
|
138
|
-
|
139
|
+
translation = model.human_attribute_name("#{key}.#{value_key}")
|
140
|
+
dbml_output << " #{value_key} [note: '#{translation}']"
|
139
141
|
end
|
140
142
|
|
141
143
|
dbml_output << "}\n"
|
@@ -151,6 +153,8 @@ module Active
|
|
151
153
|
return 'boolean'
|
152
154
|
when 'datetime(6)'
|
153
155
|
return 'datetime'
|
156
|
+
when 'INTEGER'
|
157
|
+
return 'bigint'
|
154
158
|
else
|
155
159
|
return sql_type
|
156
160
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-dbml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ukmshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|