Reverse Perl SQL::Abstract : feed a SQL and return a Hash
Ruby
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.rvmrc
Gemfile
README.markdown
Rakefile
abstract-sql.gemspec

README.markdown

Abstract SQL

You ca use this project to transform a SQL string into a Perl SQL::Abstract statement format (as a Hash)

Usage

All you need to do is to add this line in your Gemfile

  gem 'abstract-sql'

Then use it like this :

statement = "(id = 1 AND label like '%webo%') OR (id !=1 and label like '%api%')"
abstract = SQL::Abstract.new
abstract.parse statement
#=> {
      :"-or"=>
        [{:"-and"=>[{:"-="=>{:id=>1}}, {:"-like"=>{:label=>"%webo%"}}]},
         {:"-and"=>[{:"-!="=>{:id=>1}}, {:"-like"=>{:label=>"%api%"}}]}
        ]
    }