activerecord-crate-adapter 0.0.2 → 0.0.3
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/.travis.yml +10 -6
- data/CONTRIBUTING.rst +90 -0
- data/LICENSE +219 -0
- data/NOTICE +11 -0
- data/README.md +7 -10
- data/activerecord-crate-adapter.gemspec +25 -6
- data/history.txt +5 -0
- data/lib/active_record/attribute_methods/crate_object.rb +21 -0
- data/lib/active_record/connection_adapters/crate/database_statements.rb +24 -15
- data/lib/active_record/connection_adapters/crate/schema_statements.rb +21 -0
- data/lib/active_record/connection_adapters/crate_adapter.rb +21 -0
- data/lib/activerecord-crate-adapter.rb +22 -1
- data/lib/activerecord-crate-adapter/version.rb +22 -1
- data/lib/arel/arel_crate.rb +22 -1
- data/lib/arel/visitors/crate.rb +21 -0
- data/spec/activerecord/connection_adapters/crate/table_definition_spec.rb +21 -0
- data/spec/data_types/array_spec.rb +21 -0
- data/spec/data_types/object_spec.rb +21 -0
- data/spec/dummy/app/models/address.rb +21 -0
- data/spec/dummy/app/models/post.rb +21 -0
- data/spec/dummy/app/models/user.rb +21 -0
- data/spec/models/post_spec.rb +44 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/test_server.rb +23 -2
- data/spec/travis_test_server.rb +75 -0
- metadata +31 -40
- data/LICENSE.txt +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c92b2e7b75c81dd6a9311fa896e68b2f7fb7f11f
|
4
|
+
data.tar.gz: 68fba8a8fd6fa57c4c4c134a235b5d8a87a2c545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6bbd362b466ffc8757f2dbe464b2fe25f136244161819ff95f4b79c6e9c928dd5e0e66ba0017a51b9f1d64a7f09cb497bbe23a5ae8ce6e2f170995ff6229ba2
|
7
|
+
data.tar.gz: 45b2e48e6699be970d98613bc9f4368fe5aa4de1f9715a7b2aad11fdf84b00956e0957cb507ec788ce40dc2495137ac822ceaf7bd909d3257a9fffebd7a3b019
|
data/.travis.yml
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- "1.9.2"
|
4
3
|
- "1.9.3"
|
5
4
|
- "2.1.1"
|
6
5
|
- "2.0.0"
|
7
|
-
- jruby-18mode # JRuby in 1.8 mode
|
8
|
-
- jruby-19mode # JRuby in 1.9 mode
|
9
|
-
- rbx
|
10
|
-
- rbx-2
|
11
6
|
# uncomment this line if your project needs to run something other than `rake`:
|
12
|
-
|
7
|
+
|
8
|
+
before_script:
|
9
|
+
- wget https://cdn.crate.io/downloads/releases/crate-0.39.0.tar.gz -O /tmp/crate.tar.gz
|
10
|
+
- tar -xvf /tmp/crate.tar.gz
|
11
|
+
- ls
|
12
|
+
- echo $PWD
|
13
|
+
- bundle exec ruby spec/travis_test_server.rb $PWD/crate-0.39.0/ 4209
|
14
|
+
|
15
|
+
script: bundle exec rspec spec
|
16
|
+
|
data/CONTRIBUTING.rst
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
Contributing to Crate Active Record Adapter
|
2
|
+
===========================================
|
3
|
+
|
4
|
+
Thanks for considering contributing to crate active record adapter.
|
5
|
+
|
6
|
+
|
7
|
+
Reporting an issue
|
8
|
+
------------------
|
9
|
+
|
10
|
+
- Search existing issues before raising a new one.
|
11
|
+
|
12
|
+
- include as much details as possible. This might include:
|
13
|
+
|
14
|
+
- Which OS you're using.
|
15
|
+
|
16
|
+
- Which version you've been running.
|
17
|
+
|
18
|
+
- Logs/Stacktrace of the error that occurred.
|
19
|
+
|
20
|
+
- Steps to reproduce.
|
21
|
+
|
22
|
+
|
23
|
+
Pull requests
|
24
|
+
-------------
|
25
|
+
|
26
|
+
Before we can accept any pull requests to CRATE Active Record Adapter we need you to agree to
|
27
|
+
our CLA_. Once that is done, we suggest to continue as follows:
|
28
|
+
|
29
|
+
- Add an issue on Github and let us know that you're working on something.
|
30
|
+
|
31
|
+
- Use a feature branch, not master.
|
32
|
+
|
33
|
+
- Rebase your feature branch onto origin/master before raising the PR
|
34
|
+
|
35
|
+
- Be descriptive in your PR and commit messages. What is it for, why is it
|
36
|
+
needed, etc.
|
37
|
+
|
38
|
+
- Squash related commits
|
39
|
+
|
40
|
+
.. _CLA: https://crate.io/contribute/agreements/
|
41
|
+
|
42
|
+
|
43
|
+
Rebase
|
44
|
+
------
|
45
|
+
|
46
|
+
If while you've been working in the feature branch new commits were added to
|
47
|
+
the master branch please don't merge them but use rebase::
|
48
|
+
|
49
|
+
git fetch origin
|
50
|
+
git rebase origin/master
|
51
|
+
|
52
|
+
This will apply all commits on your feature branch on top of the master branch.
|
53
|
+
Any conflicts can be resolved just the same as if ``git merge`` was used. After
|
54
|
+
the conflict has been resolved use ``git rebase --continue`` to continue the
|
55
|
+
rebase process.
|
56
|
+
|
57
|
+
|
58
|
+
Squash
|
59
|
+
------
|
60
|
+
|
61
|
+
Minor commits that only fix typos or rename variables that are related to a
|
62
|
+
bigger change should be squashed into that commit.
|
63
|
+
|
64
|
+
This can be done using ``git rebase -i ( <hash> | <branch> )``
|
65
|
+
|
66
|
+
For example while working on a feature branch you'd use::
|
67
|
+
|
68
|
+
git add .
|
69
|
+
git commit -m "implemented feature XY"
|
70
|
+
|
71
|
+
# push and ask for a merge/review
|
72
|
+
|
73
|
+
git add .
|
74
|
+
git commit --fixup $(git rev-parse HEAD)
|
75
|
+
|
76
|
+
# push and ask for a merge/review
|
77
|
+
|
78
|
+
git add .
|
79
|
+
git commit --fixup $(git rev-parse HEAD)
|
80
|
+
|
81
|
+
git rebase -i origin/master
|
82
|
+
|
83
|
+
``git commit --fixup`` will mark the commit as a fixup relating to the commit
|
84
|
+
HEAD currently points to.
|
85
|
+
|
86
|
+
This is useful because ``git rebase -i`` will then automatically recognize the
|
87
|
+
fixup commits and mark them to squash. But in order for that to work the
|
88
|
+
``autosquash`` setting has to be enabled in the ``.gitconfig``::
|
89
|
+
|
90
|
+
git config --global rebase.autosquash true
|
data/LICENSE
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
CRATE Active Record Adapter
|
2
|
+
Copyright 2013-2014 CRATE Technology GmbH ("Crate")
|
3
|
+
|
4
|
+
|
5
|
+
Licensed to CRATE Technology GmbH (referred to in this notice as "Crate")
|
6
|
+
under one or more contributor license agreements. See the NOTICE file
|
7
|
+
distributed with this work for additional information regarding copyright
|
8
|
+
ownership.
|
9
|
+
|
10
|
+
Crate licenses this software to you under the Apache License, Version 2.0.
|
11
|
+
However, if you have executed another commercial license agreement with
|
12
|
+
Crate these terms will supersede the license and you may use the software
|
13
|
+
solely pursuant to the terms of the relevant commercial agreement.
|
14
|
+
|
15
|
+
|
16
|
+
=========================================================================
|
17
|
+
|
18
|
+
|
19
|
+
Apache License
|
20
|
+
Version 2.0, January 2004
|
21
|
+
http://www.apache.org/licenses/
|
22
|
+
|
23
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
24
|
+
|
25
|
+
1. Definitions.
|
26
|
+
|
27
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
28
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
29
|
+
|
30
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
31
|
+
the copyright owner that is granting the License.
|
32
|
+
|
33
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
34
|
+
other entities that control, are controlled by, or are under common
|
35
|
+
control with that entity. For the purposes of this definition,
|
36
|
+
"control" means (i) the power, direct or indirect, to cause the
|
37
|
+
direction or management of such entity, whether by contract or
|
38
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
39
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
40
|
+
|
41
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
42
|
+
exercising permissions granted by this License.
|
43
|
+
|
44
|
+
"Source" form shall mean the preferred form for making modifications,
|
45
|
+
including but not limited to software source code, documentation
|
46
|
+
source, and configuration files.
|
47
|
+
|
48
|
+
"Object" form shall mean any form resulting from mechanical
|
49
|
+
transformation or translation of a Source form, including but
|
50
|
+
not limited to compiled object code, generated documentation,
|
51
|
+
and conversions to other media types.
|
52
|
+
|
53
|
+
"Work" shall mean the work of authorship, whether in Source or
|
54
|
+
Object form, made available under the License, as indicated by a
|
55
|
+
copyright notice that is included in or attached to the work
|
56
|
+
(an example is provided in the Appendix below).
|
57
|
+
|
58
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
59
|
+
form, that is based on (or derived from) the Work and for which the
|
60
|
+
editorial revisions, annotations, elaborations, or other modifications
|
61
|
+
represent, as a whole, an original work of authorship. For the purposes
|
62
|
+
of this License, Derivative Works shall not include works that remain
|
63
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
64
|
+
the Work and Derivative Works thereof.
|
65
|
+
|
66
|
+
"Contribution" shall mean any work of authorship, including
|
67
|
+
the original version of the Work and any modifications or additions
|
68
|
+
to that Work or Derivative Works thereof, that is intentionally
|
69
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
70
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
71
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
72
|
+
means any form of electronic, verbal, or written communication sent
|
73
|
+
to the Licensor or its representatives, including but not limited to
|
74
|
+
communication on electronic mailing lists, source code control systems,
|
75
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
76
|
+
Licensor for the purpose of discussing and improving the Work, but
|
77
|
+
excluding communication that is conspicuously marked or otherwise
|
78
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
79
|
+
|
80
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
81
|
+
on behalf of whom a Contribution has been received by Licensor and
|
82
|
+
subsequently incorporated within the Work.
|
83
|
+
|
84
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
85
|
+
this License, each Contributor hereby grants to You a perpetual,
|
86
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
87
|
+
copyright license to reproduce, prepare Derivative Works of,
|
88
|
+
publicly display, publicly perform, sublicense, and distribute the
|
89
|
+
Work and such Derivative Works in Source or Object form.
|
90
|
+
|
91
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
92
|
+
this License, each Contributor hereby grants to You a perpetual,
|
93
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
94
|
+
(except as stated in this section) patent license to make, have made,
|
95
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
96
|
+
where such license applies only to those patent claims licensable
|
97
|
+
by such Contributor that are necessarily infringed by their
|
98
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
99
|
+
with the Work to which such Contribution(s) was submitted. If You
|
100
|
+
institute patent litigation against any entity (including a
|
101
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
102
|
+
or a Contribution incorporated within the Work constitutes direct
|
103
|
+
or contributory patent infringement, then any patent licenses
|
104
|
+
granted to You under this License for that Work shall terminate
|
105
|
+
as of the date such litigation is filed.
|
106
|
+
|
107
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
108
|
+
Work or Derivative Works thereof in any medium, with or without
|
109
|
+
modifications, and in Source or Object form, provided that You
|
110
|
+
meet the following conditions:
|
111
|
+
|
112
|
+
(a) You must give any other recipients of the Work or
|
113
|
+
Derivative Works a copy of this License; and
|
114
|
+
|
115
|
+
(b) You must cause any modified files to carry prominent notices
|
116
|
+
stating that You changed the files; and
|
117
|
+
|
118
|
+
(c) You must retain, in the Source form of any Derivative Works
|
119
|
+
that You distribute, all copyright, patent, trademark, and
|
120
|
+
attribution notices from the Source form of the Work,
|
121
|
+
excluding those notices that do not pertain to any part of
|
122
|
+
the Derivative Works; and
|
123
|
+
|
124
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
125
|
+
distribution, then any Derivative Works that You distribute must
|
126
|
+
include a readable copy of the attribution notices contained
|
127
|
+
within such NOTICE file, excluding those notices that do not
|
128
|
+
pertain to any part of the Derivative Works, in at least one
|
129
|
+
of the following places: within a NOTICE text file distributed
|
130
|
+
as part of the Derivative Works; within the Source form or
|
131
|
+
documentation, if provided along with the Derivative Works; or,
|
132
|
+
within a display generated by the Derivative Works, if and
|
133
|
+
wherever such third-party notices normally appear. The contents
|
134
|
+
of the NOTICE file are for informational purposes only and
|
135
|
+
do not modify the License. You may add Your own attribution
|
136
|
+
notices within Derivative Works that You distribute, alongside
|
137
|
+
or as an addendum to the NOTICE text from the Work, provided
|
138
|
+
that such additional attribution notices cannot be construed
|
139
|
+
as modifying the License.
|
140
|
+
|
141
|
+
You may add Your own copyright statement to Your modifications and
|
142
|
+
may provide additional or different license terms and conditions
|
143
|
+
for use, reproduction, or distribution of Your modifications, or
|
144
|
+
for any such Derivative Works as a whole, provided Your use,
|
145
|
+
reproduction, and distribution of the Work otherwise complies with
|
146
|
+
the conditions stated in this License.
|
147
|
+
|
148
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
149
|
+
any Contribution intentionally submitted for inclusion in the Work
|
150
|
+
by You to the Licensor shall be under the terms and conditions of
|
151
|
+
this License, without any additional terms or conditions.
|
152
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
153
|
+
the terms of any separate license agreement you may have executed
|
154
|
+
with Licensor regarding such Contributions.
|
155
|
+
|
156
|
+
6. Trademarks. This License does not grant permission to use the trade
|
157
|
+
names, trademarks, service marks, or product names of the Licensor,
|
158
|
+
except as required for reasonable and customary use in describing the
|
159
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
160
|
+
|
161
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
162
|
+
agreed to in writing, Licensor provides the Work (and each
|
163
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
164
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
165
|
+
implied, including, without limitation, any warranties or conditions
|
166
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
167
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
168
|
+
appropriateness of using or redistributing the Work and assume any
|
169
|
+
risks associated with Your exercise of permissions under this License.
|
170
|
+
|
171
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
172
|
+
whether in tort (including negligence), contract, or otherwise,
|
173
|
+
unless required by applicable law (such as deliberate and grossly
|
174
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
175
|
+
liable to You for damages, including any direct, indirect, special,
|
176
|
+
incidental, or consequential damages of any character arising as a
|
177
|
+
result of this License or out of the use or inability to use the
|
178
|
+
Work (including but not limited to damages for loss of goodwill,
|
179
|
+
work stoppage, computer failure or malfunction, or any and all
|
180
|
+
other commercial damages or losses), even if such Contributor
|
181
|
+
has been advised of the possibility of such damages.
|
182
|
+
|
183
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
184
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
185
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
186
|
+
or other liability obligations and/or rights consistent with this
|
187
|
+
License. However, in accepting such obligations, You may act only
|
188
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
189
|
+
of any other Contributor, and only if You agree to indemnify,
|
190
|
+
defend, and hold each Contributor harmless for any liability
|
191
|
+
incurred by, or claims asserted against, such Contributor by reason
|
192
|
+
of your accepting any such warranty or additional liability.
|
193
|
+
|
194
|
+
END OF TERMS AND CONDITIONS
|
195
|
+
|
196
|
+
APPENDIX: How to apply the Apache License to your work.
|
197
|
+
|
198
|
+
To apply the Apache License to your work, attach the following
|
199
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
200
|
+
replaced with your own identifying information. (Don't include
|
201
|
+
the brackets!) The text should be enclosed in the appropriate
|
202
|
+
comment syntax for the file format. We also recommend that a
|
203
|
+
file or class name and description of purpose be included on the
|
204
|
+
same "printed page" as the copyright notice for easier
|
205
|
+
identification within third-party archives.
|
206
|
+
|
207
|
+
Copyright [yyyy] [name of copyright owner]
|
208
|
+
|
209
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
210
|
+
you may not use this file except in compliance with the License.
|
211
|
+
You may obtain a copy of the License at
|
212
|
+
|
213
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
214
|
+
|
215
|
+
Unless required by applicable law or agreed to in writing, software
|
216
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
217
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
218
|
+
See the License for the specific language governing permissions and
|
219
|
+
limitations under the License.
|
data/NOTICE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Crate Data Adapter for ActiveRecord
|
2
|
+
Copyright 2013-2014 CRATE Technology GmbH ("Crate")
|
3
|
+
|
4
|
+
|
5
|
+
=========================================================================
|
6
|
+
|
7
|
+
Copyright (2014) by Christoph Klocker (http://www.vedanova.com)
|
8
|
+
Special thanks go to Christoph for launching and writing the
|
9
|
+
main parts of this project.
|
10
|
+
|
11
|
+
=========================================================================
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
[](http://badge.fury.io/rb/activerecord-crate-adapter)
|
2
|
+
[](https://travis-ci.org/crate/activerecord-crate-adapter)
|
3
|
+
[](https://codeclimate.com/github/crate/activerecord-crate-adapter)
|
2
4
|
|
3
5
|
The [Crate](http://www.crate.io) adapter for ActiveRecord.
|
4
6
|
|
@@ -129,19 +131,14 @@ then run the tests
|
|
129
131
|
|
130
132
|
## Contributing
|
131
133
|
|
132
|
-
|
134
|
+
If you think something is missing, either create a pull request
|
133
135
|
or log a new issue, so someone else can tackle it.
|
134
|
-
|
135
|
-
1. Fork it ( `http://github.com/crate/activerecord-crate-adapter/fork` )
|
136
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
137
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
138
|
-
4. Add tests
|
139
|
-
5. Push to the branch (`git push origin my-new-feature`)
|
140
|
-
6. Create new Pull Request
|
136
|
+
Please refer to CONTRIBUTING.rst for further information.
|
141
137
|
|
142
138
|
##Maintainer
|
143
139
|
|
140
|
+
* [CRATE Technology GmbH](http://crate.io)
|
144
141
|
* [Christoph Klocker](http://www.vedanova.com), [@corck](http://www.twitter.com/corck)
|
145
142
|
|
146
|
-
##License
|
147
|
-
|
143
|
+
##License & Copyright
|
144
|
+
See LICENSE for details.
|
@@ -1,4 +1,24 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
2
22
|
lib = File.expand_path('../lib', __FILE__)
|
3
23
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
24
|
require 'activerecord-crate-adapter/version'
|
@@ -6,12 +26,12 @@ require 'activerecord-crate-adapter/version'
|
|
6
26
|
Gem::Specification.new do |spec|
|
7
27
|
spec.name = "activerecord-crate-adapter"
|
8
28
|
spec.version = ActiverecordCrateAdapter::VERSION
|
9
|
-
spec.authors = ["Christoph Klocker"]
|
10
|
-
spec.email = ["
|
29
|
+
spec.authors = ["Christoph Klocker", "CRATE Technology GmbH"]
|
30
|
+
spec.email = ["office@crate.io"]
|
11
31
|
spec.summary = "ActiveRecord Crate Data Adapter"
|
12
|
-
spec.description = "ActiveRecord adapter for Crate, a shared-nothing, fully searchable, document-oriented cluster data store."
|
32
|
+
spec.description = "ActiveRecord adapter for Crate Data, a shared-nothing, fully searchable, document-oriented cluster data store."
|
13
33
|
spec.homepage = "https://crate.io"
|
14
|
-
spec.license = "
|
34
|
+
spec.license = "Apache License, v2.0"
|
15
35
|
|
16
36
|
spec.files = `git ls-files -z`.split("\x0")
|
17
37
|
#spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -20,11 +40,10 @@ Gem::Specification.new do |spec|
|
|
20
40
|
|
21
41
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
42
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "debugger"
|
24
43
|
spec.add_development_dependency "rspec", "~> 2.14"
|
25
44
|
|
26
45
|
spec.add_dependency('activerecord', '>= 4.0.0')
|
27
46
|
spec.add_dependency('arel', '>= 4.0.0')
|
28
|
-
spec.add_dependency('crate_ruby', '~> 0.0.
|
47
|
+
spec.add_dependency('crate_ruby', '~> 0.0.6')
|
29
48
|
|
30
49
|
end
|
data/history.txt
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
module CrateObject
|
2
23
|
extend ActiveSupport::Concern
|
3
24
|
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
module ActiveRecord
|
2
23
|
module ConnectionAdapters
|
3
24
|
module DatabaseStatements
|
@@ -10,27 +31,15 @@ module ActiveRecord
|
|
10
31
|
ActiveRecord::Result.new(fields, result.values)
|
11
32
|
end
|
12
33
|
|
13
|
-
# Converts an arel AST to SQL
|
14
|
-
def to_sql(arel, binds = [])
|
15
|
-
if arel.respond_to?(:ast)
|
16
|
-
binds = binds.dup
|
17
|
-
visitor.accept(arel.ast) do
|
18
|
-
quote(*binds.shift.reverse)
|
19
|
-
end
|
20
|
-
else
|
21
|
-
arel
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
34
|
def do_exec_query(sql, name, binds)
|
26
35
|
params = []
|
27
36
|
binds.each_with_index do |(column, value), index|
|
28
37
|
ar_column = column.is_a?(ActiveRecord::ConnectionAdapters::Column)
|
29
38
|
# only quote where clause values
|
30
39
|
unless ar_column # && column.sql_type == 'timestamp'
|
31
|
-
|
32
|
-
|
33
|
-
|
40
|
+
v = value
|
41
|
+
quoted_value = ar_column ? quote(v, column) : quote(v, nil)
|
42
|
+
params << quoted_value
|
34
43
|
else
|
35
44
|
params << value
|
36
45
|
end
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
module ActiveRecord
|
2
23
|
module ConnectionAdapters
|
3
24
|
module Crate
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
require 'active_record'
|
2
23
|
require 'active_record/base'
|
3
24
|
require 'active_record/base'
|
@@ -1,2 +1,23 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
require 'active_record/connection_adapters/crate_adapter'
|
2
|
-
require 'arel/visitors/crate'
|
23
|
+
require 'arel/visitors/crate'
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
module ActiverecordCrateAdapter
|
2
|
-
VERSION = "0.0.
|
23
|
+
VERSION = "0.0.3"
|
3
24
|
end
|
data/lib/arel/arel_crate.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
require 'arel'
|
2
23
|
require 'arel/visitors/crate'
|
3
|
-
require 'arel/visitors/bind_visitor'
|
24
|
+
require 'arel/visitors/bind_visitor'
|
data/lib/arel/visitors/crate.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
module Arel
|
2
23
|
module Visitors
|
3
24
|
class Crate < Arel::Visitors::ToSql
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
require_relative '../../../spec_helper'
|
2
23
|
|
3
24
|
describe ActiveRecord::ConnectionAdapters::CrateAdapter::TableDefinition do
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
require_relative '../spec_helper'
|
2
23
|
|
3
24
|
describe "Post#array" do
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
require_relative '../spec_helper'
|
2
23
|
|
3
24
|
describe "User#object" do
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
require 'active_record/attribute_methods/crate_object'
|
2
23
|
|
3
24
|
class Address
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
class Post < ActiveRecord::Base
|
2
23
|
before_create :set_id
|
3
24
|
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
class User < ActiveRecord::Base
|
2
23
|
before_create :set_id
|
3
24
|
|
data/spec/models/post_spec.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
require_relative '../spec_helper'
|
2
23
|
|
3
24
|
describe Post do
|
@@ -91,5 +112,28 @@ describe Post do
|
|
91
112
|
end
|
92
113
|
end
|
93
114
|
|
115
|
+
describe 'sql input sanitization' do
|
116
|
+
|
117
|
+
before do
|
118
|
+
@post = Post.create!(params)
|
119
|
+
end
|
120
|
+
|
121
|
+
after do
|
122
|
+
@post.destroy
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should not return all records but sanitize string' do
|
126
|
+
sql = Post.where(id: "#{@post.id} or 1=1").to_sql
|
127
|
+
sql.should match(/'#{@post.id} or 1=1'/)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should not drop the table but sanitize string' do
|
131
|
+
Post.where(id: "#{@post.title}; DROP TABLE POST")
|
132
|
+
refresh_posts
|
133
|
+
Post.last.id.should eq @post.id
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
94
138
|
end
|
95
139
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. Crate licenses
|
6
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License. You may
|
8
|
+
# obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
#
|
18
|
+
# However, if you have executed another commercial license agreement
|
19
|
+
# with Crate these terms will supersede the license and you may use the
|
20
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
|
1
22
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
23
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
24
|
require 'activerecord-crate-adapter'
|
data/spec/test_server.rb
CHANGED
@@ -1,4 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8; -*-
|
3
|
+
#
|
4
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
5
|
+
# license agreements. See the NOTICE file distributed with this work for
|
6
|
+
# additional information regarding copyright ownership. Crate licenses
|
7
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License. You may
|
9
|
+
# obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
#
|
19
|
+
# However, if you have executed another commercial license agreement
|
20
|
+
# with Crate these terms will supersede the license and you may use the
|
21
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
2
22
|
|
3
23
|
require 'net/http'
|
4
24
|
class TestServer
|
@@ -14,7 +34,7 @@ class TestServer
|
|
14
34
|
end
|
15
35
|
|
16
36
|
def start
|
17
|
-
cmd = "sh #{
|
37
|
+
cmd = "sh #{File.join(@crate_home, 'bin/crate')} #{start_params}"
|
18
38
|
@pid = spawn(cmd, :out => "/tmp/crate_test_server.out", :err => "/tmp/crate_test_server.err")
|
19
39
|
Process.detach(@pid)
|
20
40
|
puts 'starting'
|
@@ -62,7 +82,8 @@ class TestServer
|
|
62
82
|
|
63
83
|
end
|
64
84
|
|
65
|
-
server = TestServer.new
|
85
|
+
server = TestServer.new *ARGV
|
86
|
+
server.start
|
66
87
|
|
67
88
|
trap("INT") do
|
68
89
|
puts "Script terminated by user."
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8; -*-
|
3
|
+
#
|
4
|
+
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
5
|
+
# license agreements. See the NOTICE file distributed with this work for
|
6
|
+
# additional information regarding copyright ownership. Crate licenses
|
7
|
+
# this file to you under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License. You may
|
9
|
+
# obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
#
|
19
|
+
# However, if you have executed another commercial license agreement
|
20
|
+
# with Crate these terms will supersede the license and you may use the
|
21
|
+
# software solely pursuant to the terms of the relevant commercial agreement.
|
22
|
+
|
23
|
+
require 'net/http'
|
24
|
+
class TestServer
|
25
|
+
CRATE_PATH = "~/crate"
|
26
|
+
TEST_PORT = 4209
|
27
|
+
NAME = "TestCluster"
|
28
|
+
|
29
|
+
|
30
|
+
def initialize(crate_home = nil, port = nil)
|
31
|
+
@crate_home = crate_home
|
32
|
+
@port = port
|
33
|
+
@host = "127.0.0.1"
|
34
|
+
end
|
35
|
+
|
36
|
+
def start
|
37
|
+
cmd = "sh #{File.join(@crate_home, 'bin/crate')} #{start_params}"
|
38
|
+
@pid = spawn(cmd, :out => "/tmp/crate_test_server.out", :err => "/tmp/crate_test_server.err")
|
39
|
+
Process.detach(@pid)
|
40
|
+
puts 'starting'
|
41
|
+
time_slept = 0
|
42
|
+
while !alive?
|
43
|
+
puts "Crate not yet fully available. Waiting since #{time_slept} seconds..."
|
44
|
+
sleep(2)
|
45
|
+
time_slept += 2
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def start_params
|
52
|
+
"-Des.index.storage.type=memory " +
|
53
|
+
"-Des.node.name=#{NAME} " +
|
54
|
+
"-Des.cluster.name=Testing#{@port} " +
|
55
|
+
"-Des.http.port=#{@port}-#{@port} " +
|
56
|
+
"-Des.network.host=localhost " +
|
57
|
+
"-Des.discovery.type=zen " +
|
58
|
+
"-Des.discovery.zen.ping.multicast.enabled=false"
|
59
|
+
end
|
60
|
+
|
61
|
+
def alive?
|
62
|
+
req = Net::HTTP::Get.new('/')
|
63
|
+
resp = Net::HTTP.new(@host, @port)
|
64
|
+
begin
|
65
|
+
response = resp.start { |http| http.request(req) }
|
66
|
+
response.code == "200" ? true : false
|
67
|
+
rescue Errno::ECONNREFUSED
|
68
|
+
false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
server = TestServer.new *ARGV
|
75
|
+
server.start
|
metadata
CHANGED
@@ -1,125 +1,114 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-crate-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Klocker
|
8
|
+
- CRATE Technology GmbH
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- -
|
18
|
+
- - ~>
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '1.5'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- -
|
25
|
+
- - ~>
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '1.5'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rake
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- -
|
32
|
+
- - '>='
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: '0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: debugger
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
39
|
+
- - '>='
|
53
40
|
- !ruby/object:Gem::Version
|
54
41
|
version: '0'
|
55
42
|
- !ruby/object:Gem::Dependency
|
56
43
|
name: rspec
|
57
44
|
requirement: !ruby/object:Gem::Requirement
|
58
45
|
requirements:
|
59
|
-
- -
|
46
|
+
- - ~>
|
60
47
|
- !ruby/object:Gem::Version
|
61
48
|
version: '2.14'
|
62
49
|
type: :development
|
63
50
|
prerelease: false
|
64
51
|
version_requirements: !ruby/object:Gem::Requirement
|
65
52
|
requirements:
|
66
|
-
- -
|
53
|
+
- - ~>
|
67
54
|
- !ruby/object:Gem::Version
|
68
55
|
version: '2.14'
|
69
56
|
- !ruby/object:Gem::Dependency
|
70
57
|
name: activerecord
|
71
58
|
requirement: !ruby/object:Gem::Requirement
|
72
59
|
requirements:
|
73
|
-
- -
|
60
|
+
- - '>='
|
74
61
|
- !ruby/object:Gem::Version
|
75
62
|
version: 4.0.0
|
76
63
|
type: :runtime
|
77
64
|
prerelease: false
|
78
65
|
version_requirements: !ruby/object:Gem::Requirement
|
79
66
|
requirements:
|
80
|
-
- -
|
67
|
+
- - '>='
|
81
68
|
- !ruby/object:Gem::Version
|
82
69
|
version: 4.0.0
|
83
70
|
- !ruby/object:Gem::Dependency
|
84
71
|
name: arel
|
85
72
|
requirement: !ruby/object:Gem::Requirement
|
86
73
|
requirements:
|
87
|
-
- -
|
74
|
+
- - '>='
|
88
75
|
- !ruby/object:Gem::Version
|
89
76
|
version: 4.0.0
|
90
77
|
type: :runtime
|
91
78
|
prerelease: false
|
92
79
|
version_requirements: !ruby/object:Gem::Requirement
|
93
80
|
requirements:
|
94
|
-
- -
|
81
|
+
- - '>='
|
95
82
|
- !ruby/object:Gem::Version
|
96
83
|
version: 4.0.0
|
97
84
|
- !ruby/object:Gem::Dependency
|
98
85
|
name: crate_ruby
|
99
86
|
requirement: !ruby/object:Gem::Requirement
|
100
87
|
requirements:
|
101
|
-
- -
|
88
|
+
- - ~>
|
102
89
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.0.
|
90
|
+
version: 0.0.6
|
104
91
|
type: :runtime
|
105
92
|
prerelease: false
|
106
93
|
version_requirements: !ruby/object:Gem::Requirement
|
107
94
|
requirements:
|
108
|
-
- -
|
95
|
+
- - ~>
|
109
96
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.0.
|
111
|
-
description: ActiveRecord adapter for Crate, a shared-nothing, fully searchable,
|
112
|
-
cluster data store.
|
97
|
+
version: 0.0.6
|
98
|
+
description: ActiveRecord adapter for Crate Data, a shared-nothing, fully searchable,
|
99
|
+
document-oriented cluster data store.
|
113
100
|
email:
|
114
|
-
-
|
101
|
+
- office@crate.io
|
115
102
|
executables: []
|
116
103
|
extensions: []
|
117
104
|
extra_rdoc_files: []
|
118
105
|
files:
|
119
|
-
-
|
120
|
-
-
|
106
|
+
- .gitignore
|
107
|
+
- .travis.yml
|
108
|
+
- CONTRIBUTING.rst
|
121
109
|
- Gemfile
|
122
|
-
- LICENSE
|
110
|
+
- LICENSE
|
111
|
+
- NOTICE
|
123
112
|
- README.md
|
124
113
|
- Rakefile
|
125
114
|
- activerecord-crate-adapter.gemspec
|
@@ -143,9 +132,10 @@ files:
|
|
143
132
|
- spec/models/post_spec.rb
|
144
133
|
- spec/spec_helper.rb
|
145
134
|
- spec/test_server.rb
|
135
|
+
- spec/travis_test_server.rb
|
146
136
|
homepage: https://crate.io
|
147
137
|
licenses:
|
148
|
-
-
|
138
|
+
- Apache License, v2.0
|
149
139
|
metadata: {}
|
150
140
|
post_install_message:
|
151
141
|
rdoc_options: []
|
@@ -153,17 +143,17 @@ require_paths:
|
|
153
143
|
- lib
|
154
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
145
|
requirements:
|
156
|
-
- -
|
146
|
+
- - '>='
|
157
147
|
- !ruby/object:Gem::Version
|
158
148
|
version: '0'
|
159
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
150
|
requirements:
|
161
|
-
- -
|
151
|
+
- - '>='
|
162
152
|
- !ruby/object:Gem::Version
|
163
153
|
version: '0'
|
164
154
|
requirements: []
|
165
155
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.0.3
|
167
157
|
signing_key:
|
168
158
|
specification_version: 4
|
169
159
|
summary: ActiveRecord Crate Data Adapter
|
@@ -178,3 +168,4 @@ test_files:
|
|
178
168
|
- spec/models/post_spec.rb
|
179
169
|
- spec/spec_helper.rb
|
180
170
|
- spec/test_server.rb
|
171
|
+
- spec/travis_test_server.rb
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Christoph Klocker
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|