-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix TimeInDay issues * Fix issue when using DISTINCT with JOIN in models with custom SELECT clause defined AFTER the joins. * Fix mistake in spec and add specs * Add changelog; update shard * Add seed command in the CLI * add `or_where` feature * Fix FTS to remove ambiguous clauses * Fix issue with nilable belongs_to which cannot be saved when set to nil * Add RFC3339 support while converting string to time * Fix caching with belongs_to * Add colorize parameter to Clear::SQL::Logger module * Migration: Add datatype conversion in add_column and alter_column methods * Migration: Update migration add_column operation to allow contraints, nullable and default value * Update to latest version of pg gem * Fix ambigous column name in with_xxx method for belongs_to relation * Add possibility to have nulls first and nulls last in `order_by` method * WIP on a SQL parser * Add the possibility to convert from Array(JSON:Any) * Fix misc typos
- Loading branch information
Showing
30 changed files
with
617 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
name: clear | ||
version: 0.7.2 | ||
|
||
version: 0.8 | ||
|
||
authors: | ||
- Yacine Petitprez <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require "../spec_helper" | ||
|
||
module ModelDifferentColumnNameSpec | ||
class Brand | ||
include Clear::Model | ||
|
||
primary_key | ||
column name : String, column_name: "brand_name" | ||
self.table = "brands" | ||
end | ||
|
||
class ModelDifferentColumnNameSpecMigration8273 | ||
include Clear::Migration | ||
|
||
def change(dir) | ||
create_table "brands" do |t| | ||
t.column "brand_name", "string" | ||
|
||
t.timestamps | ||
end | ||
end | ||
end | ||
|
||
def self.reinit | ||
reinit_migration_manager | ||
ModelDifferentColumnNameSpecMigration8273.new.apply(Clear::Migration::Direction::UP) | ||
end | ||
|
||
describe "Clear::Model" do | ||
context "Column definition" do | ||
it "can define properties in the model with a name different of the column name in PG" do | ||
# Here the column "name" is linked to "brand_name" in postgreSQL | ||
temporary do | ||
reinit | ||
|
||
Brand.create! name: "Nike" | ||
Brand.query.first!.name.should eq "Nike" | ||
Brand.query.where(brand_name: "Nike").count.should eq 1 | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require "../spec_helper" | ||
|
||
module ParserSpec | ||
extend self | ||
|
||
describe "Clear::SQL" do | ||
describe "Parser" do | ||
|
||
it "parse correctly" do | ||
Clear::SQL::Parser.parse(<<-SQL | ||
SELECT * FROM "users" where (id > 100 and active is null); | ||
SELECT 'string' as text; | ||
-- This is a comment | ||
SQL | ||
) do |token| | ||
pp token | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Clear::CLI::Seed < Admiral::Command | ||
include Clear::CLI::Command | ||
|
||
define_help description: "Seed the database with seed data" | ||
|
||
def run_impl | ||
Clear.apply_seeds | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.