Skip to content

Commit 3ad48b7

Browse files
committed
Replace add_row() by insert() in some tests
At some point we'll deprecate add_row(), tests that don't explicitly test add_row() should use insert().
1 parent 33bfa3b commit 3ad48b7

File tree

5 files changed

+45
-43
lines changed

5 files changed

+45
-43
lines changed

tests/data/test_output_flex_nodes.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ tables.t2 = osm2pgsql.define_node_table('osm2pgsql_test_t2', {
1313

1414
function osm2pgsql.process_node(object)
1515
if object.tags.t1 then
16-
tables.t1:add_row({
17-
tags = object.tags
16+
tables.t1:insert({
17+
tags = object.tags,
18+
geom = object:as_point()
1819
})
1920
end
2021
if object.tags.t2 then
21-
tables.t2:add_row({
22-
tags = object.tags
22+
tables.t2:insert({
23+
tags = object.tags,
24+
geom = object:as_point()
2325
})
2426
end
2527
end

tests/data/test_output_flex_relation_combinations.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function osm2pgsql.select_relation_members(relation)
88
end
99

1010
function osm2pgsql.process_relation(object)
11-
rel_table:add_row({
11+
rel_table:insert({
1212
tags = object.tags
1313
})
1414
end

tests/data/test_output_flex_relations.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ tables.t2 = osm2pgsql.define_relation_table('osm2pgsql_test_t2', {
1111

1212
function osm2pgsql.process_relation(object)
1313
if object.tags.t1 then
14-
tables.t1:add_row({
14+
tables.t1:insert({
1515
tags = object.tags
1616
})
1717
end
1818
if object.tags.t2 then
19-
tables.t2:add_row({
19+
tables.t2:insert({
2020
tags = object.tags
2121
})
2222
end

tests/data/test_output_flex_schema.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ function osm2pgsql.process_way(object)
1717
return
1818
end
1919

20-
dtable:add_row({
20+
dtable:insert({
2121
tags = object.tags,
22-
geom = { create = 'line' }
22+
geom = object:as_linestring()
2323
})
2424
end
2525

tests/data/test_output_flex_types.lua

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ function osm2pgsql.process_node(object)
1616
local test_type = object.tags.type
1717

1818
if test_type == 'nil' then
19-
test_table:add_row()
19+
test_table:insert({})
2020
return
2121
end
2222
if test_type == 'boolean' then
2323
local row = { tbool = true, tint2 = true, tint4 = true,
2424
tint8 = true, tjson = true, tdirn = true }
25-
test_table:add_row(row)
25+
test_table:insert(row)
2626

2727
row = { tbool = false, tint2 = false, tint4 = false,
2828
tint8 = false, tjson = false, tdirn = false }
29-
test_table:add_row(row)
29+
test_table:insert(row)
3030
return
3131
end
3232
if test_type == 'boolean-fail' then
33-
test_table:add_row{ [object.tags.column] = true }
33+
test_table:insert{ [object.tags.column] = true }
3434
return
3535
end
3636
if test_type == 'number' then
@@ -40,7 +40,7 @@ function osm2pgsql.process_node(object)
4040
2^15 - 1, 2^15, 2^15 + 1,
4141
2^31 - 1, 2^31, 2^31 + 1 }
4242
for _, n in ipairs(numbers) do
43-
test_table:add_row{
43+
test_table:insert{
4444
ttext = n,
4545
tbool = n,
4646
tint2 = n,
@@ -55,36 +55,36 @@ function osm2pgsql.process_node(object)
5555
return
5656
end
5757
if test_type == 'number-fail' then
58-
test_table:add_row{ [object.tags.column] = 1 }
58+
test_table:insert{ [object.tags.column] = 1 }
5959
return
6060
end
6161
if test_type == 'string-bool' then
62-
test_table:add_row{ tbool = '1', ttext = 'istrue' };
63-
test_table:add_row{ tbool = 'yes', ttext = 'istrue' };
64-
test_table:add_row{ tbool = 'true', ttext = 'istrue' };
62+
test_table:insert{ tbool = '1', ttext = 'istrue' };
63+
test_table:insert{ tbool = 'yes', ttext = 'istrue' };
64+
test_table:insert{ tbool = 'true', ttext = 'istrue' };
6565

66-
test_table:add_row{ tbool = '0', ttext = 'isfalse' };
67-
test_table:add_row{ tbool = 'no', ttext = 'isfalse' };
68-
test_table:add_row{ tbool = 'false', ttext = 'isfalse' };
66+
test_table:insert{ tbool = '0', ttext = 'isfalse' };
67+
test_table:insert{ tbool = 'no', ttext = 'isfalse' };
68+
test_table:insert{ tbool = 'false', ttext = 'isfalse' };
6969

70-
test_table:add_row{ tbool = '', ttext = 'isnull' };
71-
test_table:add_row{ tbool = '2', ttext = 'isnull' };
72-
test_table:add_row{ tbool = 'YES', ttext = 'isnull' };
70+
test_table:insert{ tbool = '', ttext = 'isnull' };
71+
test_table:insert{ tbool = '2', ttext = 'isnull' };
72+
test_table:insert{ tbool = 'YES', ttext = 'isnull' };
7373
return
7474
end
7575
if test_type == 'string-direction' then
76-
test_table:add_row{ tdirn = '1', tint2 = 1 };
77-
test_table:add_row{ tdirn = 'yes', tint2 = 1 };
76+
test_table:insert{ tdirn = '1', tint2 = 1 };
77+
test_table:insert{ tdirn = 'yes', tint2 = 1 };
7878

79-
test_table:add_row{ tdirn = '0', tint2 = 0 };
80-
test_table:add_row{ tdirn = 'no', tint2 = 0 };
79+
test_table:insert{ tdirn = '0', tint2 = 0 };
80+
test_table:insert{ tdirn = 'no', tint2 = 0 };
8181

82-
test_table:add_row{ tdirn = '-1', tint2 = -1 };
82+
test_table:insert{ tdirn = '-1', tint2 = -1 };
8383

84-
test_table:add_row{ tdirn = '2', tint2 = nil };
85-
test_table:add_row{ tdirn = '-2', tint2 = nil };
86-
test_table:add_row{ tdirn = '', tint2 = nil };
87-
test_table:add_row{ tdirn = 'FOO', tint2 = nil };
84+
test_table:insert{ tdirn = '2', tint2 = nil };
85+
test_table:insert{ tdirn = '-2', tint2 = nil };
86+
test_table:insert{ tdirn = '', tint2 = nil };
87+
test_table:insert{ tdirn = 'FOO', tint2 = nil };
8888
return
8989
end
9090
if test_type == 'string-with-number' then
@@ -94,7 +94,7 @@ function osm2pgsql.process_node(object)
9494
2^15 - 1, 2^15, 2^15 + 1,
9595
2^31 - 1, 2^31, 2^31 + 1 }
9696
for _, n in ipairs(numbers) do
97-
test_table:add_row{
97+
test_table:insert{
9898
ttext = string.format('%d', n),
9999
tint2 = string.format('%d', n),
100100
tint4 = string.format('%d', n),
@@ -103,7 +103,7 @@ function osm2pgsql.process_node(object)
103103
tsqlt = string.format('%d', n),
104104
}
105105
end
106-
test_table:add_row{
106+
test_table:insert{
107107
ttext = ' 42',
108108
tint2 = ' 42',
109109
tint4 = ' 42',
@@ -116,7 +116,7 @@ function osm2pgsql.process_node(object)
116116
if test_type == 'string-with-invalid-number' then
117117
local not_numbers = { '', 'abc', '0a', '0xa', '--1', '1foo', '1.2' }
118118
for _, n in ipairs(not_numbers) do
119-
test_table:add_row{
119+
test_table:insert{
120120
ttext = n,
121121
tint2 = n,
122122
tint4 = n,
@@ -127,25 +127,25 @@ function osm2pgsql.process_node(object)
127127
return
128128
end
129129
if test_type == 'function-fail' then
130-
test_table:add_row{ [object.tags.column] = table.insert }
130+
test_table:insert{ [object.tags.column] = table.insert }
131131
return
132132
end
133133
if test_type == 'table' then
134134
local t = { a = 'b', c = 'd' }
135-
test_table:add_row{ thstr = {}, tjson = {} }
136-
test_table:add_row{ thstr = t, tjson = t }
135+
test_table:insert{ thstr = {}, tjson = {} }
136+
test_table:insert{ thstr = t, tjson = t }
137137
return
138138
end
139139
if test_type == 'table-hstore-fail' then
140-
test_table:add_row{ thstr = { num = 1, bln = true } }
140+
test_table:insert{ thstr = { num = 1, bln = true } }
141141
return
142142
end
143143
if test_type == 'table-fail' then
144-
test_table:add_row{ [object.tags.column] = {} }
144+
test_table:insert{ [object.tags.column] = {} }
145145
return
146146
end
147147
if test_type == 'json' then
148-
test_table:add_row{ tjson = {
148+
test_table:insert{ tjson = {
149149
astring = '123',
150150
aninteger = 124,
151151
anumber = 12.5,
@@ -160,7 +160,7 @@ function osm2pgsql.process_node(object)
160160
if test_type == 'json-loop' then
161161
local atable = { a = 'b' }
162162
atable.c = atable
163-
test_table:add_row{ tjson = atable }
163+
test_table:insert{ tjson = atable }
164164
return
165165
end
166166
end

0 commit comments

Comments
 (0)