Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junegunn/sql_helper
https://github.com/junegunn/sql_helper
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/junegunn/sql_helper
- Owner: junegunn
- License: mit
- Created: 2013-06-16T15:26:37.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-17T13:49:35.000Z (over 11 years ago)
- Last Synced: 2024-09-14T10:49:48.135Z (about 2 months ago)
- Language: Ruby
- Size: 117 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SQLHelper
A simplistic SQL generator extracted from [jdbc-helper](https://github.com/junegunn/jdbc-helper) gem.
This gem is not intended to be used independently outside the context of jdbc-helper.## Example
```ruby
SQLHelper.select(
prepared: true,
table: 'mytable',
project: %w[a b c d e],
where: [
'z <> 100',
['y = ?', 200],
{
a: "hello 'world'",
b: (1..10),
c: (1...10),
d: ['abc', "'def'"],
e: { sql: 'sysdate' },
f: { not: nil },
g: { gt: 100 },
h: { lt: 100 },
i: { like: 'ABC%' },
j: { not: { like: 'ABC%' } },
k: { le: { sql: 'sysdate' } },
l: { ge: 100, le: 200 },
m: { not: [ 150, { ge: 100, le: 200 } ] },
n: nil,
o: { not: (1..10) },
p: { or: [{ gt: 100 }, { lt: 50 }] },
q: { like: ['ABC%', 'DEF%'] },
r: { or: [{ like: ['ABC%', 'DEF%'] }, { not: { like: 'XYZ%' } }] }
}
],
order: 'a desc',
limit: 10
)
```