Methods
- S
- T
-
- test_default_sequence_name,
- test_default_sequence_name_bad_table,
- test_distinct_with_nulls,
- test_exec_insert_number,
- test_exec_insert_string,
- test_exec_no_binds,
- test_exec_typecasts_bind_vals,
- test_exec_with_binds,
- test_insert_sql_with_no_space_after_table_name,
- test_insert_sql_with_proprietary_returning_clause,
- test_insert_sql_with_quoted_schema_and_table_name,
- test_non_standard_primary_key,
- test_pk_and_sequence_for,
- test_pk_and_sequence_for_returns_nil_if_no_pk,
- test_pk_and_sequence_for_returns_nil_if_no_seq,
- test_pk_and_sequence_for_returns_nil_if_table_not_found,
- test_pk_and_sequence_for_with_non_standard_primary_key,
- test_primary_key,
- test_primary_key_raises_error_if_table_not_found,
- test_primary_key_returns_nil_for_no_pk,
- test_primary_key_works_tables_containing_capital_letters,
- test_raise_error_when_cannot_translate_exception,
- test_serial_sequence,
- test_substitute_at,
- test_table_alias_length
Instance Public methods
setup()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 6 def setup @connection = ActiveRecord::Base.connection @connection.exec_query('drop table if exists ex') @connection.exec_query('create table ex(id serial primary key, number integer, data character varying(255))') end
test_default_sequence_name()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 64 def test_default_sequence_name assert_equal 'accounts_id_seq', @connection.default_sequence_name('accounts', 'id') assert_equal 'accounts_id_seq', @connection.default_sequence_name('accounts') end
test_default_sequence_name_bad_table()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 72 def test_default_sequence_name_bad_table assert_equal 'zomg_id_seq', @connection.default_sequence_name('zomg', 'id') assert_equal 'zomg_id_seq', @connection.default_sequence_name('zomg') end
test_distinct_with_nulls()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 185 def test_distinct_with_nulls assert_equal "DISTINCT posts.title, posts.updater_id AS alias_0", @connection.distinct("posts.title", ["posts.updater_id desc nulls first"]) assert_equal "DISTINCT posts.title, posts.updater_id AS alias_0", @connection.distinct("posts.title", ["posts.updater_id desc nulls last"]) end
test_exec_insert_number()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 110 def test_exec_insert_number insert(@connection, 'number' => 10) result = @connection.exec_query('SELECT number FROM ex WHERE number = 10') assert_equal 1, result.rows.length assert_equal "10", result.rows.last.last end
test_exec_insert_string()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 119 def test_exec_insert_string str = 'いただきます!' insert(@connection, 'number' => 10, 'data' => str) result = @connection.exec_query('SELECT number, data FROM ex WHERE number = 10') value = result.rows.last.last assert_equal str, value end
test_exec_no_binds()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 136 def test_exec_no_binds result = @connection.exec_query('SELECT id, data FROM ex') assert_equal 0, result.rows.length assert_equal 2, result.columns.length assert_equal %w{ id data }, result.columns string = @connection.quote('foo') @connection.exec_query("INSERT INTO ex (id, data) VALUES (1, #{string})") result = @connection.exec_query('SELECT id, data FROM ex') assert_equal 1, result.rows.length assert_equal 2, result.columns.length assert_equal [['1', 'foo']], result.rows end
test_exec_typecasts_bind_vals()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 163 def test_exec_typecasts_bind_vals string = @connection.quote('foo') @connection.exec_query("INSERT INTO ex (id, data) VALUES (1, #{string})") column = @connection.columns('ex').find { |col| col.name == 'id' } result = @connection.exec_query( 'SELECT id, data FROM ex WHERE id = $1', nil, [[column, '1-fuu']]) assert_equal 1, result.rows.length assert_equal 2, result.columns.length assert_equal [['1', 'foo']], result.rows end
test_exec_with_binds()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 151 def test_exec_with_binds string = @connection.quote('foo') @connection.exec_query("INSERT INTO ex (id, data) VALUES (1, #{string})") result = @connection.exec_query( 'SELECT id, data FROM ex WHERE id = $1', nil, [[nil, 1]]) assert_equal 1, result.rows.length assert_equal 2, result.columns.length assert_equal [['1', 'foo']], result.rows end
test_insert_sql_with_no_space_after_table_name()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 49 def test_insert_sql_with_no_space_after_table_name id = @connection.insert_sql("insert into ex(number) values(5150)") expect = @connection.query('select max(id) from ex').first.first assert_equal expect, id end
test_insert_sql_with_proprietary_returning_clause()
Link
test_insert_sql_with_quoted_schema_and_table_name()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 43 def test_insert_sql_with_quoted_schema_and_table_name id = @connection.insert_sql('insert into "public"."ex" (number) values(5150)') expect = @connection.query('select max(id) from ex').first.first assert_equal expect, id end
test_non_standard_primary_key()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 20 def test_non_standard_primary_key @connection.exec_query('drop table if exists ex') @connection.exec_query('create table ex(data character varying(255) primary key)') assert_equal 'data', @connection.primary_key('ex') end
test_pk_and_sequence_for()
Link
test_pk_and_sequence_for_returns_nil_if_no_pk()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 100 def test_pk_and_sequence_for_returns_nil_if_no_pk @connection.exec_query('drop table if exists ex') @connection.exec_query('create table ex(id integer)') assert_nil @connection.pk_and_sequence_for('ex') end
test_pk_and_sequence_for_returns_nil_if_no_seq()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 94 def test_pk_and_sequence_for_returns_nil_if_no_seq @connection.exec_query('drop table if exists ex') @connection.exec_query('create table ex(id integer primary key)') assert_nil @connection.pk_and_sequence_for('ex') end
test_pk_and_sequence_for_returns_nil_if_table_not_found()
Link
test_pk_and_sequence_for_with_non_standard_primary_key()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 86 def test_pk_and_sequence_for_with_non_standard_primary_key @connection.exec_query('drop table if exists ex') @connection.exec_query('create table ex(code serial primary key)') pk, seq = @connection.pk_and_sequence_for('ex') assert_equal 'code', pk assert_equal @connection.default_sequence_name('ex', 'code'), seq end
test_primary_key()
Link
test_primary_key_raises_error_if_table_not_found()
Link
test_primary_key_returns_nil_for_no_pk()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 26 def test_primary_key_returns_nil_for_no_pk @connection.exec_query('drop table if exists ex') @connection.exec_query('create table ex(id integer)') assert_nil @connection.primary_key('ex') end
test_primary_key_works_tables_containing_capital_letters()
Link
test_raise_error_when_cannot_translate_exception()
Link
test_serial_sequence()
Link
# File activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb, line 55 def test_serial_sequence assert_equal 'public.accounts_id_seq', @connection.serial_sequence('accounts', 'id') assert_raises(ActiveRecord::StatementInvalid) do @connection.serial_sequence('zomg', 'id') end end
test_substitute_at()
Link