rusql 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ff1b4a10ef306cabe203f2af5da46b99e11b1f6
4
- data.tar.gz: cece6f6999111a263632519870d48bd54f9d3a63
3
+ metadata.gz: 7de70ccbf6676684b58192eeb8801799bc4b045d
4
+ data.tar.gz: 67a793c131ce5ca49d099d8bbccccda3f8e5f9da
5
5
  SHA512:
6
- metadata.gz: dfd7287e5e4040c15ba79c2ce96d259b722b7825c3604b4dace91f95fa9c627958186571416cbd4ccf04bd36bb43efd26b4b801d2d0f02469d151acae331be46
7
- data.tar.gz: 9ffb4d54d0cae07c5de2f8cdd67380fc46b4559a6b217cdf4ff6f0e836b9300ab83808ce32b1d140ae35eeb3e902129c1e129699e89222c34d42c6ce69cd5214
6
+ metadata.gz: 344a891cb2325191454bc29d05f18f963a17dbad7aad7e3875ab43cca71ab1512ca530a4a2ad8509301bdd48b98dbcddffb2a5b5a5889798ace858aa6636b87e
7
+ data.tar.gz: db12ee071da15bb594a64724cf72c3922c4df3f8ec0a3aed7f2e8ae44afa34df6bf9cf1dcae77479308d57bf954b6ba5a244476febd839b159c42e9ba88db7c0
data/lib/rusql/join.rb CHANGED
@@ -11,12 +11,14 @@ module Rusql
11
11
  )
12
12
 
13
13
  def initialize(type, table, condition)
14
+ final_table = table.is_a?(Table) ? table : ( table.respond_to?(:as_rusql_table) ? table.as_rusql_table : nil )
15
+
14
16
  raise Exception.new("Expected type to be one of #{ TYPES.map(&:to_s).join(",") }") unless TYPES.include?(type)
15
- raise TypeException.new(Table, table.class) unless table.is_a?(Table)
17
+ raise TypeException.new(Table, table.class) if final_table.nil?
16
18
  raise TypeException.new(BasicCondition, condition.class) unless condition.is_a?(BasicCondition)
17
19
 
18
20
  @type = type
19
- @table = table
21
+ @table = final_table
20
22
  @condition = condition
21
23
  end
22
24
 
data/lib/rusql/query.rb CHANGED
@@ -44,10 +44,12 @@ module Rusql
44
44
  end
45
45
 
46
46
  def from(t)
47
- raise TypeException.new(Table, t.class) unless t.is_a?(Table)
47
+ # so that we can have ActiveRecord hacks :/
48
+ final_table = t.is_a?(Table) ? t : ( t.respond_to?(:as_rusql_table) ? t.as_rusql_table : nil )
49
+ raise TypeException.new(Table, t.class) if final_table.nil?
48
50
 
49
51
  new_one = self.duplicate
50
- new_one.instance_variable_set(:@from_table, t)
52
+ new_one.instance_variable_set(:@from_table, final_table)
51
53
 
52
54
  new_one
53
55
  end
data/lib/rusql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rusql
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rusql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ajith Hussain