@@ -491,8 +491,7 @@ void output_flex_t::write_column(
491491 return ;
492492 }
493493
494- if ((column.type () == table_column_type::sql) ||
495- (column.type () == table_column_type::text)) {
494+ if (column.type () == table_column_type::text) {
496495 auto const *const str = lua_tolstring (lua_state (), -1 , nullptr );
497496 if (!str) {
498497 throw std::runtime_error{
@@ -845,7 +844,7 @@ void output_flex_t::setup_id_columns(flex_table_t *table)
845844 std::string const column_name =
846845 lua_tolstring (lua_state (), -1 , nullptr );
847846 check_name (column_name, " column" );
848- auto &column = table->add_column (column_name, " id_type" );
847+ auto &column = table->add_column (column_name, " id_type" , " " );
849848 column.set_not_null ();
850849 } else if (!lua_isnil (lua_state (), -1 )) {
851850 throw std::runtime_error{" type_column must be a string or nil." };
@@ -859,7 +858,7 @@ void output_flex_t::setup_id_columns(flex_table_t *table)
859858 luaX_get_table_string (lua_state (), " id_column" , -2 , " The ids field" );
860859 check_name (name, " column" );
861860
862- auto &column = table->add_column (name, " id_num" );
861+ auto &column = table->add_column (name, " id_num" , " " );
863862 column.set_not_null ();
864863 lua_pop (lua_state (), 3 ); // id_column, type, ids
865864}
@@ -885,21 +884,23 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table)
885884 " The entries in the 'columns' array must be tables." };
886885 }
887886
888- char const *const type =
889- luaX_get_table_string ( lua_state (), " type " , - 1 , " Column entry" );
887+ char const *const type = luaX_get_table_string ( lua_state (), " type " , - 1 ,
888+ " Column entry" , " text " );
890889 char const *const name =
891890 luaX_get_table_string (lua_state (), " column" , -2 , " Column entry" );
892891 check_name (name, " column" );
892+ char const *const sql_type = luaX_get_table_string (
893+ lua_state (), " sql_type" , -3 , " Column entry" , " " );
893894
894- auto &column = table->add_column (name, type);
895+ auto &column = table->add_column (name, type, sql_type );
895896
896- column.set_not_null (luaX_get_table_bool (lua_state (), " not_null" , -3 ,
897+ column.set_not_null (luaX_get_table_bool (lua_state (), " not_null" , -4 ,
897898 " Entry 'not_null'" , false ));
898899
899900 column.set_create_only (luaX_get_table_bool (
900- lua_state (), " create_only" , -4 , " Entry 'create_only'" , false ));
901+ lua_state (), " create_only" , -5 , " Entry 'create_only'" , false ));
901902
902- lua_getfield (lua_state (), -5 , " projection" );
903+ lua_getfield (lua_state (), -6 , " projection" );
903904 if (!lua_isnil (lua_state (), -1 )) {
904905 if (column.is_geometry_column () ||
905906 column.type () == table_column_type::area) {
@@ -910,8 +911,9 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table)
910911 }
911912 }
912913
913- // stack has: projection, create_only, not_null, column, type, table
914- lua_pop (lua_state (), 6 );
914+ // stack has: projection, create_only, not_null, sql_type, column,
915+ // type, table
916+ lua_pop (lua_state (), 7 );
915917 ++num_columns;
916918 }
917919
0 commit comments