Skip to content

Commit 31a9ec0

Browse files
committed
style: formatting
from `rake format`
1 parent efe508f commit 31a9ec0

File tree

2 files changed

+27
-30
lines changed

2 files changed

+27
-30
lines changed

ext/sqlite3/statement.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,9 @@ stmt_stat_internal(VALUE hash_or_sym, sqlite3_stmt *stmt)
473473

474474
if (RB_TYPE_P(hash_or_sym, T_HASH)) {
475475
hash = hash_or_sym;
476-
}
477-
else if (SYMBOL_P(hash_or_sym)) {
476+
} else if (SYMBOL_P(hash_or_sym)) {
478477
key = hash_or_sym;
479-
}
480-
else {
478+
} else {
481479
rb_raise(rb_eTypeError, "non-hash or symbol argument");
482480
}
483481

@@ -542,8 +540,7 @@ stat_for(VALUE self, VALUE key)
542540
if (SYMBOL_P(key)) {
543541
size_t value = stmt_stat_internal(key, ctx->st);
544542
return SIZET2NUM(value);
545-
}
546-
else {
543+
} else {
547544
rb_raise(rb_eTypeError, "non-symbol given");
548545
}
549546
}

test/test_statement.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,11 @@ def test_stat
294294
end
295295

296296
def test_stat_fullscan_steps
297-
@db.execute 'CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT);'
297+
@db.execute "CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT);"
298298
10.times do |i|
299-
@db.execute 'INSERT INTO test_table (name) VALUES (?)', "name_#{i}"
299+
@db.execute "INSERT INTO test_table (name) VALUES (?)", "name_#{i}"
300300
end
301-
@db.execute 'DROP INDEX IF EXISTS idx_test_table_id;'
301+
@db.execute "DROP INDEX IF EXISTS idx_test_table_id;"
302302
stmt = @db.prepare("SELECT * FROM test_table WHERE name LIKE 'name%'")
303303
stmt.execute.to_a
304304

@@ -308,9 +308,9 @@ def test_stat_fullscan_steps
308308
end
309309

310310
def test_stat_sorts
311-
@db.execute 'CREATE TABLE test1(a)'
312-
@db.execute 'INSERT INTO test1 VALUES (1)'
313-
stmt = @db.prepare('select * from test1 order by a')
311+
@db.execute "CREATE TABLE test1(a)"
312+
@db.execute "INSERT INTO test1 VALUES (1)"
313+
stmt = @db.prepare("select * from test1 order by a")
314314
stmt.execute.to_a
315315

316316
assert_equal 1, stmt.stat(:sorts)
@@ -322,8 +322,8 @@ def test_stat_autoindexes
322322
@db.execute "CREATE TABLE t1(a,b);"
323323
@db.execute "CREATE TABLE t2(c,d);"
324324
10.times do |i|
325-
@db.execute 'INSERT INTO t1 (a, b) VALUES (?, ?)', [i, i.to_s]
326-
@db.execute 'INSERT INTO t2 (c, d) VALUES (?, ?)', [i, i.to_s]
325+
@db.execute "INSERT INTO t1 (a, b) VALUES (?, ?)", [i, i.to_s]
326+
@db.execute "INSERT INTO t2 (c, d) VALUES (?, ?)", [i, i.to_s]
327327
end
328328
stmt = @db.prepare("SELECT * FROM t1, t2 WHERE a=c;")
329329
stmt.execute.to_a
@@ -334,9 +334,9 @@ def test_stat_autoindexes
334334
end
335335

336336
def test_stat_vm_steps
337-
@db.execute 'CREATE TABLE test1(a)'
338-
@db.execute 'INSERT INTO test1 VALUES (1)'
339-
stmt = @db.prepare('select * from test1 order by a')
337+
@db.execute "CREATE TABLE test1(a)"
338+
@db.execute "INSERT INTO test1 VALUES (1)"
339+
stmt = @db.prepare("select * from test1 order by a")
340340
stmt.execute.to_a
341341

342342
assert_operator stmt.stat(:vm_steps), :>, 0
@@ -345,12 +345,12 @@ def test_stat_vm_steps
345345
end
346346

347347
def test_stat_reprepares
348-
@db.execute 'CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT);'
348+
@db.execute "CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT);"
349349
10.times do |i|
350-
@db.execute 'INSERT INTO test_table (name) VALUES (?)', "name_#{i}"
350+
@db.execute "INSERT INTO test_table (name) VALUES (?)", "name_#{i}"
351351
end
352352
stmt = @db.prepare("SELECT * FROM test_table WHERE name LIKE ?")
353-
stmt.execute('name%').to_a
353+
stmt.execute("name%").to_a
354354

355355
if stmt.stat.key?(:reprepares)
356356
assert_equal 1, stmt.stat(:reprepares)
@@ -362,9 +362,9 @@ def test_stat_reprepares
362362
end
363363

364364
def test_stat_runs
365-
@db.execute 'CREATE TABLE test1(a)'
366-
@db.execute 'INSERT INTO test1 VALUES (1)'
367-
stmt = @db.prepare('select * from test1')
365+
@db.execute "CREATE TABLE test1(a)"
366+
@db.execute "INSERT INTO test1 VALUES (1)"
367+
stmt = @db.prepare("select * from test1")
368368
stmt.execute.to_a
369369

370370
if stmt.stat.key?(:runs)
@@ -380,8 +380,8 @@ def test_stat_filter_misses
380380
@db.execute "CREATE TABLE t1(a,b);"
381381
@db.execute "CREATE TABLE t2(c,d);"
382382
10.times do |i|
383-
@db.execute 'INSERT INTO t1 (a, b) VALUES (?, ?)', [i, i.to_s]
384-
@db.execute 'INSERT INTO t2 (c, d) VALUES (?, ?)', [i, i.to_s]
383+
@db.execute "INSERT INTO t1 (a, b) VALUES (?, ?)", [i, i.to_s]
384+
@db.execute "INSERT INTO t2 (c, d) VALUES (?, ?)", [i, i.to_s]
385385
end
386386
stmt = @db.prepare("SELECT * FROM t1, t2 WHERE a=c;")
387387
stmt.execute.to_a
@@ -399,8 +399,8 @@ def test_stat_filter_hits
399399
@db.execute "CREATE TABLE t1(a,b);"
400400
@db.execute "CREATE TABLE t2(c,d);"
401401
10.times do |i|
402-
@db.execute 'INSERT INTO t1 (a, b) VALUES (?, ?)', [i, i.to_s]
403-
@db.execute 'INSERT INTO t2 (c, d) VALUES (?, ?)', [i+1, i.to_s]
402+
@db.execute "INSERT INTO t1 (a, b) VALUES (?, ?)", [i, i.to_s]
403+
@db.execute "INSERT INTO t2 (c, d) VALUES (?, ?)", [i + 1, i.to_s]
404404
end
405405
stmt = @db.prepare("SELECT * FROM t1, t2 WHERE a=c AND b = '1' AND d = '1';")
406406
stmt.execute.to_a
@@ -415,9 +415,9 @@ def test_stat_filter_hits
415415
end
416416

417417
def test_memused
418-
@db.execute 'CREATE TABLE test1(a)'
419-
@db.execute 'INSERT INTO test1 VALUES (1)'
420-
stmt = @db.prepare('select * from test1')
418+
@db.execute "CREATE TABLE test1(a)"
419+
@db.execute "INSERT INTO test1 VALUES (1)"
420+
stmt = @db.prepare("select * from test1")
421421

422422
skip("memused not defined") unless stmt.respond_to?(:memused)
423423

0 commit comments

Comments
 (0)