Sha256: b055f8eb860c91e34363562b2a2b919b1206bc96e1828e41b405c555662bd6a9

Contents?: true

Size: 885 Bytes

Versions: 19

Compression:

Stored size: 885 Bytes

Contents

require 'test_helper'

class DatabaseTest < ActiveSupport::TestCase

  test "query" do
    User.delete_all
    User.create(name: 'Igor')
    query = RailsDb::SqlQuery.new('select count(*) as users_count from users')
    query.execute
    assert_equal query.data.columns, ['users_count']
    assert_equal query.data.rows.collect{|e| e.collect{|ee| ee.to_i}} , [[1]]
    assert_not_nil query.explain
  end

  test "insert" do
    query = RailsDb::SqlQuery.new('delete from projects_users')
    query.execute
    User.delete_all
    assert_equal 0, RailsDb::Database.count('projects_users')
    query = RailsDb::SqlQuery.new('insert into projects_users(project_id, user_id) values(1,2)')
    query.execute
    assert_equal query.data.columns, []
    assert_equal query.data.rows, []
    assert_not_nil query.explain
    assert_equal 1, RailsDb::Database.count('projects_users')
  end

end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
rails_db-2.4.4 test/sql_query_test.rb
rails_db-2.4.3 test/sql_query_test.rb
rails_db-2.4.2 test/sql_query_test.rb
rails_db-2.4.1 test/sql_query_test.rb
rails_db-2.4.0 test/sql_query_test.rb
rails_db-2.3.1 test/sql_query_test.rb
rails_db-2.3.0 test/sql_query_test.rb
rails_db-2.2.1 test/sql_query_test.rb
rails_db-2.2.0 test/sql_query_test.rb
rails_db-2.1.1 test/sql_query_test.rb
rails_db-2.1.0 test/sql_query_test.rb
rails_db-2.0.6 test/sql_query_test.rb
rails_db-2.0.5 test/sql_query_test.rb
rails_db-2.0.4 test/sql_query_test.rb
xplore-0.0.1.alpha test/sql_query_test.rb
rails_db-2.0.3 test/sql_query_test.rb
rails_db-2.0.2 test/sql_query_test.rb
rails_db-2.0.1 test/sql_query_test.rb
rails_db-2.0.0 test/sql_query_test.rb