Skip to content

Commit 4a0928b

Browse files
committed
Ensure that flex_table_t::geom_column() refers to the first one
Now that there are multiple geometry columns allowed this makes sure we always have the first one (which is important for clustering). Remove the `column.set_not_null();` in `add_column()` for geometry columns because it did not work anyway. It is overwritten by the `column.set_not_null(...)` call right outside the `add_column()` call.
1 parent 65d0d27 commit 4a0928b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/flex-table.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ flex_table_column_t &flex_table_t::add_column(std::string const &name,
7373
(m_columns.size() == 1 &&
7474
m_columns[0].type() == table_column_type::id_type));
7575

76-
m_columns.emplace_back(name, type, sql_type);
77-
auto &column = m_columns.back();
76+
auto &column = m_columns.emplace_back(name, type, sql_type);
7877

7978
if (column.is_geometry_column()) {
80-
if (m_geom_column != std::numeric_limits<std::size_t>::max()) {
79+
if (m_geom_column == std::numeric_limits<std::size_t>::max()) {
80+
m_geom_column = m_columns.size() - 1;
81+
} else {
8182
m_has_multiple_geom_columns = true;
8283
}
83-
m_geom_column = m_columns.size() - 1;
84-
column.set_not_null();
8584
}
8685

8786
return column;

src/flex-table.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class flex_table_t
110110
return m_geom_column != std::numeric_limits<std::size_t>::max();
111111
}
112112

113-
// XXX should we allow several geometry columns?
113+
/// Get the (first, if there are multiple) geometry column.
114114
flex_table_column_t const &geom_column() const noexcept
115115
{
116116
assert(has_geom_column());
@@ -218,7 +218,10 @@ class flex_table_t
218218
*/
219219
std::vector<flex_table_column_t> m_columns;
220220

221-
/// Index of the geometry column in m_columns. Default means no geometry.
221+
/**
222+
* Index of the (first) geometry column in m_columns. Default means no
223+
* geometry column.
224+
*/
222225
std::size_t m_geom_column = std::numeric_limits<std::size_t>::max();
223226

224227
/**

0 commit comments

Comments
 (0)