Project

sql_helper

0.0
No commit activity in last 3 years
No release in over 3 years
A simplistic SQL generator
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
 Project Readme

SQLHelper

A simplistic SQL generator extracted from jdbc-helper gem. This gem is not intended to be used independently outside the context of jdbc-helper.

Example

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
)