File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,10 @@ def default_attributes
100100 end
101101 if attributes_class . table_exists?
102102 return attributes_class . columns . map do |c |
103- OpenStruct . new ( { name : c . name . to_sym , type : c . type } )
103+ OpenStruct . new ( {
104+ name : c . name . to_sym ,
105+ type : convert_column_type_to_graphiti_resource_type ( c . type )
106+ } )
104107 end
105108 else
106109 raise "#{ attributes_class } table must exist. Please run migrations."
@@ -181,5 +184,34 @@ def resource_klass
181184 def type
182185 model_klass . name . underscore . pluralize
183186 end
187+
188+ def convert_column_type_to_graphiti_resource_type ( type )
189+ # TODO: Support database specific types.
190+ case type
191+ when :string , :text
192+ :string
193+ when :float , :decimal
194+ :integer
195+ when :integer , :bigint
196+ :integer
197+ when :datetime , :time
198+ :datetime
199+ when :date
200+ :date
201+ when :boolean
202+ :boolean
203+ when :numeric
204+ # TODO: Return type.
205+ type
206+ when :primary_key
207+ # TODO: Return type.
208+ type
209+ when :binary
210+ # TODO: Return type.
211+ type
212+ else
213+ type
214+ end
215+ end
184216 end
185217end
You can’t perform that action at this time.
0 commit comments