Skip to content

Commit

Permalink
Rename project to axiom-sql-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
dkubb committed Apr 4, 2013
1 parent 43d7442 commit 59b205d
Show file tree
Hide file tree
Showing 118 changed files with 380 additions and 380 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -2,7 +2,7 @@

source 'https://rubygems.org'

gem 'veritas', '~> 0.0.8', :git => 'https://github.com/dkubb/veritas.git'
gem 'axiom', '~> 0.0.8', :git => 'https://github.com/dkubb/axiom.git'

gem 'devtools', :git => 'https://github.com/datamapper/devtools.git'
eval File.read('Gemfile.devtools')
38 changes: 19 additions & 19 deletions README.md
@@ -1,40 +1,40 @@
veritas-sql-generator
=====================
axiom-sql-generator
===================

Relational algebra SQL generator

[![Gem Version](https://badge.fury.io/rb/veritas-sql-generator.png)][gem]
[![Build Status](https://secure.travis-ci.org/dkubb/veritas-sql-generator.png?branch=master)][travis]
[![Dependency Status](https://gemnasium.com/dkubb/veritas-sql-generator.png)][gemnasium]
[![Code Climate](https://codeclimate.com/github/dkubb/veritas-sql-generator.png)][codeclimate]
[![Coverage Status](https://coveralls.io/repos/dkubb/veritas-sql-generator/badge.png?branch=master)][coveralls]
[![Gem Version](https://badge.fury.io/rb/axiom-sql-generator.png)][gem]
[![Build Status](https://secure.travis-ci.org/dkubb/axiom-sql-generator.png?branch=master)][travis]
[![Dependency Status](https://gemnasium.com/dkubb/axiom-sql-generator.png)][gemnasium]
[![Code Climate](https://codeclimate.com/github/dkubb/axiom-sql-generator.png)][codeclimate]
[![Coverage Status](https://coveralls.io/repos/dkubb/axiom-sql-generator/badge.png?branch=master)][coveralls]

[gem]: https://rubygems.org/gems/veritas-sql-generator
[travis]: https://travis-ci.org/dkubb/veritas-sql-generator
[gemnasium]: https://gemnasium.com/dkubb/veritas-sql-generator
[codeclimate]: https://codeclimate.com/github/dkubb/veritas-sql-generator
[coveralls]: https://coveralls.io/r/dkubb/veritas-sql-generator
[gem]: https://rubygems.org/gems/axiom-sql-generator
[travis]: https://travis-ci.org/dkubb/axiom-sql-generator
[gemnasium]: https://gemnasium.com/dkubb/axiom-sql-generator
[codeclimate]: https://codeclimate.com/github/dkubb/axiom-sql-generator
[coveralls]: https://coveralls.io/r/dkubb/axiom-sql-generator

Installation
------------

With Rubygems:

```bash
$ gem install veritas-sql-generator
$ gem install axiom-sql-generator
$ irb -rubygems
>> require 'veritas-sql-generator'
>> require 'axiom-sql-generator'
=> true
```

With git and local working copy:

```bash
$ git clone git://github.com/dkubb/veritas-sql-generator.git
$ cd veritas-sql-generator
$ git clone git://github.com/dkubb/axiom-sql-generator.git
$ cd axiom-sql-generator
$ rake install
$ irb -rubygems
>> require 'veritas-sql-generator'
>> require 'axiom-sql-generator'
=> true
```

Expand All @@ -43,7 +43,7 @@ Usage

```ruby
# visit every node in the relation AST
generator = Veritas::SQL::Generator::Relation.visit(relation)
generator = Axiom::SQL::Generator::Relation.visit(relation)

# generate an SQL string
sql = generator.to_sql
Expand All @@ -55,7 +55,7 @@ subquery_sql = generator.to_subquery
Description
-----------

The purpose of this gem is to produce valid SQL from a [veritas](https://github.com/dkubb/veritas) relation. A relation is a representation of a query constructed using relational algebra organized into an AST. Each node in the AST corresponds to an operation defined in the algebra.
The purpose of this gem is to produce valid SQL from a [axiom](https://github.com/dkubb/axiom) relation. A relation is a representation of a query constructed using relational algebra organized into an AST. Each node in the AST corresponds to an operation defined in the algebra.

The SQL produced has been verified and tested against [PostgreSQL](http://www.postgresql.org/) 9.0.4. Dialects for [MySQL](http://www.mysql.com/), [SQLite](http://www.sqlite.org/), [Oracle](http://www.oracle.com/) and [SQL Server](http://www.microsoft.com/sqlserver/) are planned.

Expand Down
6 changes: 3 additions & 3 deletions TODO
Expand Up @@ -5,9 +5,9 @@
special cases.
* Use different classes for inclusive/exclusive Range literals so that
they can be serialized to SQL differently.
* Create Veritas::Literal::Range proxy object w/factory method
* Create Veritas::Literal::Range::Inclusive
* Create Veritas::Literal::Range::Exclusive
* Create Axiom::Literal::Range proxy object w/factory method
* Create Axiom::Literal::Range::Inclusive
* Create Axiom::Literal::Range::Exclusive

* Handle cases where an Inequality/Exclusion predicate is used (or a
Negation wrapping an Equality/Inclusion) on an *optional* attribute.
Expand Down
12 changes: 6 additions & 6 deletions veritas-sql-generator.gemspec → axiom-sql-generator.gemspec
@@ -1,23 +1,23 @@
# encoding: utf-8

require File.expand_path('../lib/veritas/sql/generator/version', __FILE__)
require File.expand_path('../lib/axiom/sql/generator/version', __FILE__)

Gem::Specification.new do |gem|
gem.name = 'veritas-sql-generator'
gem.version = Veritas::SQL::Generator::VERSION.dup
gem.name = 'axiom-sql-generator'
gem.version = Axiom::SQL::Generator::VERSION.dup
gem.authors = ['Dan Kubb']
gem.email = 'dan.kubb@gmail.com'
gem.description = 'Generate SQL from a veritas relation'
gem.description = 'Generate SQL from a axiom relation'
gem.summary = 'Relational algebra SQL generator'
gem.homepage = 'https://github.com/dkubb/veritas-sql-generator'
gem.homepage = 'https://github.com/dkubb/axiom-sql-generator'
gem.licenses = %w[MIT]

gem.require_paths = %w[lib]
gem.files = `git ls-files`.split($/)
gem.test_files = `git ls-files -- spec/{unit,integration}`.split($/)
gem.extra_rdoc_files = %w[LICENSE README.md TODO]

gem.add_runtime_dependency('veritas', '~> 0.0.7')
gem.add_runtime_dependency('axiom', '~> 0.0.7')

gem.add_development_dependency('rake', '~> 10.0.4')
gem.add_development_dependency('rspec', '~> 2.13.0')
Expand Down
4 changes: 2 additions & 2 deletions config/mutant.yml
@@ -1,3 +1,3 @@
---
name: veritas-sql-generator
namespace: Veritas::SQL::Generator
name: axiom-sql-generator
namespace: Axiom::SQL::Generator
116 changes: 58 additions & 58 deletions config/reek.yml
Expand Up @@ -2,7 +2,7 @@
Attribute:
enabled: true
exclude:
- Veritas::SQL::Generator::Relation
- Axiom::SQL::Generator::Relation
BooleanParameter:
enabled: true
exclude: []
Expand All @@ -15,7 +15,7 @@ ControlParameter:
DataClump:
enabled: true
exclude:
- Veritas::SQL::Generator::Function
- Axiom::SQL::Generator::Function
max_copies: 2
min_clump_size: 2
DuplicateMethodCall:
Expand All @@ -26,22 +26,22 @@ DuplicateMethodCall:
FeatureEnvy:
enabled: true
exclude:
- Veritas::SQL::Generator::Function::Predicate#new_from_enumerable_predicate
- Veritas::SQL::Generator::Function::Predicate#optional?
- Veritas::SQL::Generator::Function::Predicate#visit_veritas_function_predicate_inequality
- Veritas::SQL::Generator::Identifier#visit_identifier
- Veritas::SQL::Generator::Identifier#visit_identifier
- Veritas::SQL::Generator::Literal#visit_numeric
- Veritas::SQL::Generator::Literal#visit_string
- Veritas::SQL::Generator::Literal#visit_string
- Veritas::SQL::Generator::Relation#column_list_for
- Axiom::SQL::Generator::Function::Predicate#new_from_enumerable_predicate
- Axiom::SQL::Generator::Function::Predicate#optional?
- Axiom::SQL::Generator::Function::Predicate#visit_veritas_function_predicate_inequality
- Axiom::SQL::Generator::Identifier#visit_identifier
- Axiom::SQL::Generator::Identifier#visit_identifier
- Axiom::SQL::Generator::Literal#visit_numeric
- Axiom::SQL::Generator::Literal#visit_string
- Axiom::SQL::Generator::Literal#visit_string
- Axiom::SQL::Generator::Relation#column_list_for
IrresponsibleModule:
enabled: true
exclude: []
LongParameterList:
enabled: true
exclude:
- Veritas::SQL::Generator::Function::Predicate#new_from_enumerable_predicate
- Axiom::SQL::Generator::Function::Predicate#new_from_enumerable_predicate
max_params: 2
overrides:
initialize:
Expand All @@ -53,69 +53,69 @@ LongYieldList:
NestedIterators:
enabled: true
exclude:
- Veritas::SQL::Generator::Relation::Materialized#visit_veritas_relation_materialized
- Veritas::SQL::Generator::Visitor#self.handlers
- Axiom::SQL::Generator::Relation::Materialized#visit_veritas_relation_materialized
- Axiom::SQL::Generator::Visitor#self.handlers
max_allowed_nesting: 1
ignore_iterators: []
NilCheck:
enabled: true
exclude:
- Veritas::SQL::Generator::Function::Predicate#inequality_sql
- Veritas::SQL::Generator::Function::Predicate#visit_veritas_function_predicate_equality
- Axiom::SQL::Generator::Function::Predicate#inequality_sql
- Axiom::SQL::Generator::Function::Predicate#visit_veritas_function_predicate_equality
RepeatedConditional:
enabled: true
exclude:
- Veritas::SQL::Generator::Relation
- Axiom::SQL::Generator::Relation
max_ifs: 1
TooManyInstanceVariables:
enabled: true
exclude:
- Veritas::SQL::Generator::Relation::Binary
- Veritas::SQL::Generator::Relation::Unary
- Axiom::SQL::Generator::Relation::Binary
- Axiom::SQL::Generator::Relation::Unary
max_instance_variables: 3
TooManyMethods:
enabled: true
exclude:
- Veritas::SQL::Generator::Relation
- Veritas::SQL::Generator::Relation::Unary
- Axiom::SQL::Generator::Relation
- Axiom::SQL::Generator::Relation::Unary
max_methods: 10
TooManyStatements:
enabled: true
exclude:
- Date#iso8601
- DateTime#iso8601_timediv
- Veritas::SQL::Generator::Function::Predicate#exclusive_range_exclusion_sql
- Veritas::SQL::Generator::Function::Predicate#exclusive_range_inclusion_sql
- Veritas::SQL::Generator::Function::Predicate#inequality_expressions
- Veritas::SQL::Generator::Function::Predicate#visit_veritas_function_predicate_inequality
- Veritas::SQL::Generator::Literal#visit_class
- Veritas::SQL::Generator::Relation#column_list_for
- Veritas::SQL::Generator::Relation#columns_for
- Veritas::SQL::Generator::Relation#implicit_columns
- Veritas::SQL::Generator::Relation#self.visit
- Veritas::SQL::Generator::Relation::Binary#set_operands
- Veritas::SQL::Generator::Relation::Binary#visit_veritas_algebra_join
- Veritas::SQL::Generator::Relation::Binary#visit_veritas_algebra_product
- Veritas::SQL::Generator::Relation::Insertion#visit_veritas_relation_operation_insertion
- Veritas::SQL::Generator::Relation::Materialized#generate_sql
- Veritas::SQL::Generator::Relation::Set#self.normalize_operand_headers
- Veritas::SQL::Generator::Relation::Set#visit_veritas_algebra_difference
- Veritas::SQL::Generator::Relation::Set#visit_veritas_algebra_intersection
- Veritas::SQL::Generator::Relation::Set#visit_veritas_algebra_union
- Veritas::SQL::Generator::Relation::Unary#reset_query_state
- Veritas::SQL::Generator::Relation::Unary#subquery_for
- Veritas::SQL::Generator::Relation::Unary#summarize_per
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_algebra_extension
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_algebra_projection
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_algebra_rename
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_algebra_restriction
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_algebra_summarization
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_relation_base
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_relation_operation_binary
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_relation_operation_limit
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_relation_operation_offset
- Veritas::SQL::Generator::Relation::Unary#visit_veritas_relation_operation_order
- Veritas::SQL::Generator::Visitor#self.method_for
- Axiom::SQL::Generator::Function::Predicate#exclusive_range_exclusion_sql
- Axiom::SQL::Generator::Function::Predicate#exclusive_range_inclusion_sql
- Axiom::SQL::Generator::Function::Predicate#inequality_expressions
- Axiom::SQL::Generator::Function::Predicate#visit_veritas_function_predicate_inequality
- Axiom::SQL::Generator::Literal#visit_class
- Axiom::SQL::Generator::Relation#column_list_for
- Axiom::SQL::Generator::Relation#columns_for
- Axiom::SQL::Generator::Relation#implicit_columns
- Axiom::SQL::Generator::Relation#self.visit
- Axiom::SQL::Generator::Relation::Binary#set_operands
- Axiom::SQL::Generator::Relation::Binary#visit_veritas_algebra_join
- Axiom::SQL::Generator::Relation::Binary#visit_veritas_algebra_product
- Axiom::SQL::Generator::Relation::Insertion#visit_veritas_relation_operation_insertion
- Axiom::SQL::Generator::Relation::Materialized#generate_sql
- Axiom::SQL::Generator::Relation::Set#self.normalize_operand_headers
- Axiom::SQL::Generator::Relation::Set#visit_veritas_algebra_difference
- Axiom::SQL::Generator::Relation::Set#visit_veritas_algebra_intersection
- Axiom::SQL::Generator::Relation::Set#visit_veritas_algebra_union
- Axiom::SQL::Generator::Relation::Unary#reset_query_state
- Axiom::SQL::Generator::Relation::Unary#subquery_for
- Axiom::SQL::Generator::Relation::Unary#summarize_per
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_algebra_extension
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_algebra_projection
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_algebra_rename
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_algebra_restriction
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_algebra_summarization
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_relation_base
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_relation_operation_binary
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_relation_operation_limit
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_relation_operation_offset
- Axiom::SQL::Generator::Relation::Unary#visit_veritas_relation_operation_order
- Axiom::SQL::Generator::Visitor#self.method_for
- each
max_statements: 2
UncommunicativeMethodName:
Expand Down Expand Up @@ -157,9 +157,9 @@ UnusedParameters:
UtilityFunction:
enabled: true
exclude:
- Veritas::SQL::Generator::Function::Predicate#new_from_enumerable_predicate
- Veritas::SQL::Generator::Function::Predicate#optional?
- Veritas::SQL::Generator::Identifier#visit_identifier
- Veritas::SQL::Generator::Literal#visit_numeric
- Veritas::SQL::Generator::Literal#visit_string
- Axiom::SQL::Generator::Function::Predicate#new_from_enumerable_predicate
- Axiom::SQL::Generator::Function::Predicate#optional?
- Axiom::SQL::Generator::Identifier#visit_identifier
- Axiom::SQL::Generator::Literal#visit_numeric
- Axiom::SQL::Generator::Literal#visit_string
max_helper_calls: 0
3 changes: 3 additions & 0 deletions lib/axiom-sql-generator.rb
@@ -0,0 +1,3 @@
# encoding: utf-8

require 'axiom/sql/generator'
61 changes: 61 additions & 0 deletions lib/axiom/sql/generator.rb
@@ -0,0 +1,61 @@
# encoding: utf-8

require 'date'
require 'time'

require 'axiom'

require 'axiom/sql/generator/core_ext/date'
require 'axiom/sql/generator/core_ext/date_time'

require 'axiom/sql/generator/visitor'

require 'axiom/sql/generator/identifier'
require 'axiom/sql/generator/attribute'
require 'axiom/sql/generator/direction'
require 'axiom/sql/generator/literal'

require 'axiom/sql/generator/function'
require 'axiom/sql/generator/function/aggregate'
require 'axiom/sql/generator/function/connective'
require 'axiom/sql/generator/function/numeric'
require 'axiom/sql/generator/function/predicate'
require 'axiom/sql/generator/function/proposition'
require 'axiom/sql/generator/function/string'

require 'axiom/sql/generator/relation'
require 'axiom/sql/generator/relation/unary'
require 'axiom/sql/generator/relation/base'
require 'axiom/sql/generator/relation/binary'
require 'axiom/sql/generator/relation/materialized'
require 'axiom/sql/generator/relation/set'

require 'axiom/sql/generator/relation/insertion'

require 'axiom/sql/generator/version'

module Axiom
module SQL
module Generator

# Raised when an invalid relation is visited
class InvalidRelationError < StandardError; end

LEFT_PARENTHESIS = '('.freeze
RIGHT_PARENTHESIS = ')'.freeze

# Return a parenthesized SQL statement (inline modification)
#
# @param [#to_s] sql
#
# @return [#to_s]
# same instance as sql
#
# @api private
def self.parenthesize!(sql)
sql.insert(0, LEFT_PARENTHESIS) << RIGHT_PARENTHESIS
end

end # module Generator
end # module SQL
end # module Axiom
@@ -1,6 +1,6 @@
# encoding: utf-8

module Veritas
module Axiom
module SQL
module Generator

Expand All @@ -15,11 +15,11 @@ module Attribute
# @return [#to_s]
#
# @api private
def visit_veritas_attribute(attribute)
def visit_axiom_attribute(attribute)
visit_identifier(attribute.name)
end

end # module Attribute
end # module Generator
end # module SQL
end # module Veritas
end # module Axiom
File renamed without changes.

0 comments on commit 59b205d

Please sign in to comment.