Loading bricks/brick-sql-exec +14 −14 Original line number Diff line number Diff line Loading @@ -224,15 +224,8 @@ namespace brq::sql data += size; } void fetch_one( inet &in ) { fetch_raw( in ); } void fetch_one( bool &t ) { fetch_raw( t ); } void fetch_one( int16_t &t ) { fetch_raw( t ); t = be16toh( t ); } void fetch_one( int32_t &t ) { fetch_raw( t ); t = be32toh( t ); } void fetch_one( int64_t &t ) { fetch_raw( t ); t = be64toh( t ); } void fetch_one( timestamp &t ) { fetch_raw( t.fract ); t.fract = be64toh( t.fract ); } template< typename T, int s > void fetch_one( fixnum< s, T > &n ) { fetch_one( n.value ); } template< typename T, size_t s > void fetch_one( std::array< T, s > &n ) template< typename T > void fetch_one( const char *&data, T &out ) { fetch_one( data, sizeof( T ), out ); } Loading Loading @@ -314,8 +307,8 @@ namespace brq::sql void convert( const char *data, int64_t len, std::u32string &us ) { std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > conv; us = conv.from_bytes( data, data + PQgetlength( _result, _row, _col ) ); std::string_view s( data, len ); from_string( s, us ); } void convert( const char *data, int64_t len, std::string &s ) Loading @@ -323,6 +316,13 @@ namespace brq::sql s = std::string( data, data + len ); } template< typename... Ts > void convert( const char *data, int64_t s, enum_type< Ts... > &out ) { std::string val; fetch_one( val ); out.from_string( val ); } template< typename T > void fetch_one( std::optional< T > &opt ) { if ( PQgetisnull( _result, _row, _col ) ) Loading Loading @@ -373,9 +373,9 @@ namespace brq::sql void bind_one( std::string_view s ) { bind_mem( s.data(), s.size() ); } void bind_one( std::u32string_view us ) { std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > conv; auto str = conv.to_bytes( &*us.begin(), &*us.end() ); bind_mem( str.data(), str.size() ); brq::string_builder b; b << us; bind_mem( b.buffer(), b.size() ); } template< typename T, int s > void bind_one( fixnum< s, T > &f ) { bind_one( f.value ); } Loading bricks/brick-sql-expr +9 −1 Original line number Diff line number Diff line Loading @@ -213,7 +213,15 @@ namespace brq::sql template< typename... cols > using endomorphism = function< typename cons_list_t< cols... >::car_t::type, cols... >; template< typename col > struct count : function< int32_t, col > template< typename col > struct array_agg : function< std::vector< typename col::type >, col > { explicit array_agg( const col &c = col() ) : function< std::vector< typename col::type >, col >( c ) {} }; template< typename col, bool distinct = false > struct count : function< int32_t, col > { explicit count( const col &c = col() ) : function< int32_t, col >( c ) {} Loading Loading
bricks/brick-sql-exec +14 −14 Original line number Diff line number Diff line Loading @@ -224,15 +224,8 @@ namespace brq::sql data += size; } void fetch_one( inet &in ) { fetch_raw( in ); } void fetch_one( bool &t ) { fetch_raw( t ); } void fetch_one( int16_t &t ) { fetch_raw( t ); t = be16toh( t ); } void fetch_one( int32_t &t ) { fetch_raw( t ); t = be32toh( t ); } void fetch_one( int64_t &t ) { fetch_raw( t ); t = be64toh( t ); } void fetch_one( timestamp &t ) { fetch_raw( t.fract ); t.fract = be64toh( t.fract ); } template< typename T, int s > void fetch_one( fixnum< s, T > &n ) { fetch_one( n.value ); } template< typename T, size_t s > void fetch_one( std::array< T, s > &n ) template< typename T > void fetch_one( const char *&data, T &out ) { fetch_one( data, sizeof( T ), out ); } Loading Loading @@ -314,8 +307,8 @@ namespace brq::sql void convert( const char *data, int64_t len, std::u32string &us ) { std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > conv; us = conv.from_bytes( data, data + PQgetlength( _result, _row, _col ) ); std::string_view s( data, len ); from_string( s, us ); } void convert( const char *data, int64_t len, std::string &s ) Loading @@ -323,6 +316,13 @@ namespace brq::sql s = std::string( data, data + len ); } template< typename... Ts > void convert( const char *data, int64_t s, enum_type< Ts... > &out ) { std::string val; fetch_one( val ); out.from_string( val ); } template< typename T > void fetch_one( std::optional< T > &opt ) { if ( PQgetisnull( _result, _row, _col ) ) Loading Loading @@ -373,9 +373,9 @@ namespace brq::sql void bind_one( std::string_view s ) { bind_mem( s.data(), s.size() ); } void bind_one( std::u32string_view us ) { std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > conv; auto str = conv.to_bytes( &*us.begin(), &*us.end() ); bind_mem( str.data(), str.size() ); brq::string_builder b; b << us; bind_mem( b.buffer(), b.size() ); } template< typename T, int s > void bind_one( fixnum< s, T > &f ) { bind_one( f.value ); } Loading
bricks/brick-sql-expr +9 −1 Original line number Diff line number Diff line Loading @@ -213,7 +213,15 @@ namespace brq::sql template< typename... cols > using endomorphism = function< typename cons_list_t< cols... >::car_t::type, cols... >; template< typename col > struct count : function< int32_t, col > template< typename col > struct array_agg : function< std::vector< typename col::type >, col > { explicit array_agg( const col &c = col() ) : function< std::vector< typename col::type >, col >( c ) {} }; template< typename col, bool distinct = false > struct count : function< int32_t, col > { explicit count( const col &c = col() ) : function< int32_t, col >( c ) {} Loading