baseapi 0.1.20 → 0.1.21
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/README.md +2 -2
- data/lib/baseapi/active_record/relation_extension.rb +10 -5
- data/lib/baseapi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fb67821b5f3db39fea1ef9dd96883c4341cdede
|
4
|
+
data.tar.gz: d7ebdd268fb277a8c6f07ca499874d6088a3e2a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab5bec3a4805c440a0a52b64c62bb1822333169426703c60526bc901df682d6fc2c6c53d98bfb6a9bcd02b396692618dbf762ab487c7a7f8f1b1634831164421
|
7
|
+
data.tar.gz: 73e08bf142091102411f8dca9a293c24abadb9cbcf39f3ace5b62d7c0d0d46e0f8f98ddaa43f280c2de399205f7439e351e7009f2cf27a73341a628f18dcc95a
|
data/README.md
CHANGED
@@ -102,12 +102,12 @@ Specify the sorting order
|
|
102
102
|
GET /users.json?order=desc&orderby=name
|
103
103
|
SQL => SELECT DISTINCT `users`.* FROM `users` ORDER BY `users`.`name` DESC
|
104
104
|
|
105
|
-
Specify the multiple sorting order (v0.1.
|
105
|
+
Specify the multiple sorting order (v0.1.21~)
|
106
106
|
|
107
107
|
GET /users.json?order[]=desc&order[]=asc&orderby[]=name&orderby[]=company_id
|
108
108
|
SQL => SELECT DISTINCT `users`.* FROM `users` ORDER BY name DESC, company_id ASC
|
109
109
|
|
110
|
-
Specify the association sorting order (v0.1.
|
110
|
+
Specify the association sorting order (v0.1.21~)
|
111
111
|
|
112
112
|
GET /users.json?order=asc&orderby=company.name
|
113
113
|
SQL => SELECT DISTINCT `users`.* FROM `users` ...JOIN... ORDER BY companies.name ASC
|
@@ -82,12 +82,17 @@ module ActiveRecordRelationExtension
|
|
82
82
|
table_name = joins_tables.count > 0 ? joins_tables.last.pluralize.underscore : ''
|
83
83
|
# joins_tables exists check
|
84
84
|
joins_tables.each do |table|
|
85
|
-
next
|
85
|
+
next if !ActiveRecord::Base.connection.tables.include?(table.pluralize.underscore)
|
86
|
+
end
|
87
|
+
if table_name.present?
|
88
|
+
# table exists check
|
89
|
+
next if table_name.present? and !ActiveRecord::Base.connection.tables.include?(table_name)
|
90
|
+
# column_name exists check
|
91
|
+
next if !table_name.camelize.singularize.constantize.column_names.include?(column_name)
|
92
|
+
else
|
93
|
+
# column_name exists check
|
94
|
+
next if !self.model.column_names.include?(column_name)
|
86
95
|
end
|
87
|
-
# table_name exists check
|
88
|
-
next unless ActiveRecord::Base.connection.tables.include?(table_name)
|
89
|
-
# column_name exists check
|
90
|
-
next unless table_name.camelize.singularize.constantize.column_names.include?(column_name)
|
91
96
|
# joins
|
92
97
|
joins_array!(joins_tables)
|
93
98
|
# order
|
data/lib/baseapi/version.rb
CHANGED