0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 21:04:15 +08:00
Commit Graph

935 Commits

Author SHA1 Message Date
Roland Bock
715839e18f More moves 2024-07-28 21:04:26 +02:00
Roland Bock
44ce033845 Move more stuff 2024-07-28 20:56:27 +02:00
Roland Bock
df8e2b6c81 Move clauses into sub directory 2024-07-28 20:24:05 +02:00
Roland Bock
6a92f139b7 More tests fixed
Make as_expression usable in select only
2024-07-28 15:04:22 +02:00
Roland Bock
2b7b568c49 Continue fixing tests 2024-07-27 13:15:56 +02:00
Roland Bock
6a11df89ec Change table represenation
Move columns out of table template parameters
2024-07-26 12:11:38 +02:00
Roland Bock
5578cce232 Rewrite select_as and add type tests 2024-07-25 08:05:18 +02:00
Roland Bock
4630bf7f0c More type tests 2024-07-21 19:33:33 +02:00
Roland Bock
25faf6c4bb More tests 2024-07-21 13:04:17 +02:00
Roland Bock
d3daa90e0b custom_query tests 2024-07-21 12:01:37 +02:00
Roland Bock
01c1e69eb3 More tests 2024-07-21 10:43:27 +02:00
Roland Bock
d2cb720746 Reactivate more tests 2024-07-21 09:24:41 +02:00
Roland Bock
4e75cf349b Start reactivating tests 2024-07-21 07:57:01 +02:00
Roland Bock
0f4d3b1451 Reduce error messages for serialize, add first serialize test for dynamic AND 2024-07-18 20:49:16 +02:00
Roland Bock
7cc4e45abd Add dynamic to AND and OR 2024-07-18 20:17:57 +02:00
Roland Bock
700c263f90 Introduce dynamic
This allows to select columns dynamically
2024-07-18 07:38:45 +02:00
Roland Bock
25200ba4cb (Only) allow comparison with ANY and introduce BETWEEN 2024-07-17 07:44:21 +02:00
Roland Bock
937dd31a13 Migrate column_t::as to using operator::as 2024-07-16 07:37:03 +02:00
Roland Bock
bdd87b9e03 Add enable_as 2024-07-15 07:57:08 +02:00
Roland Bock
2d2f08007a Single column select has a value type 2024-07-15 07:44:29 +02:00
Roland Bock
6c1d59ffc4 Remove data type wrappers (with compile failuers) 2024-07-14 19:57:55 +02:00
Roland Bock
61030742b3 Removing more instances of wrap_operand 2024-07-14 12:42:02 +02:00
Roland Bock
87f4c348e9 Added more tests and cleaned up type traits a bit 2024-07-13 21:04:06 +02:00
Roland Bock
c2c5f15690 Add basic serialize functions and start documenting differences 2024-07-13 13:39:36 +02:00
Roland Bock
2b7e0ee6a5 Give operators a value 2024-07-11 20:46:30 +02:00
Roland Bock
08f643460c No more type traits in generated code 2024-07-09 08:08:53 +02:00
Roland Bock
4baede7434 Started to remove operand wrapping 2024-07-08 21:08:16 +02:00
Roland Bock
6eb791430a More testing 2024-06-30 10:31:41 +02:00
Roland Bock
c70ceaceb0 Introduce optional select columns
Basic functionality seems to work, more tests needed.
2024-06-25 07:33:53 +02:00
Roland Bock
b869cbe5b2 Synchronize sql and generated code for connector tests 2024-06-22 16:27:10 +02:00
Roland Bock
0eac55c377 Move optional, string_view, and span into sqlpp::compat 2024-06-12 21:31:18 +02:00
Roland Bock
8d0f3b3739 Clean up superfluous classes and functions
And remove some remaining dynamic parts which were overlooked before.
2024-06-12 20:33:35 +02:00
Roland Bock
c347b5d11c Remove dynamic query components 2024-06-12 20:31:06 +02:00
Roland Bock
bda77c620b Introduce optional, string_view, and span
sqlpp::optional is an alias for std::optional for C++17 and beyond.
Otherwise, it is a simple and incomplete backport.
For older versions of C++, the library offers simple back

Similar for string_view and span.
2024-06-12 20:29:10 +02:00
Roland Bock
ac9d0b4417 Update the documentation for NULL #568 2024-04-13 08:56:57 +02:00
Roland Bock
eb2e569c2b Add time of day paramter for mysql #565 2024-04-05 07:35:13 +02:00
Roland Bock
ce13f2a783 Add time of day support for mysql connector #563 2024-03-29 10:55:56 +01:00
Roland Bock
fdbe08946b Add size() function to mysql::char_result_t #562 2024-03-24 09:20:54 +01:00
Roland Bock
93ab3fef86 Throw exception for multi-statements in sqlite3 execute #558
Before this change, sqlite3::connection::execute silently
ignores statements after the first one (separated by semicolon).

After this change, trailing statements are detected and an
sqlpp::exception is thrown.

This change also adds documentation to other connectors indicating
that execute is supposed to be used with single statements only,
even though it is possible to do otherwise.
2024-03-09 10:54:16 +01:00
MeanSquaredError
dccf3438d3
Add a missing break to the switch case that handles PostgreSQL errors 40XXX. (#552) 2024-01-06 08:41:48 +01:00
MeanSquaredError
0cc45bd790
PostgreSQL exceptions for serialization_failure and deadlock_detected (#551)
* Add the exception sqlpp::postgresql::serialization_failure
* Add the exception sqlpp::postgresql::deadlock_detected
2024-01-05 09:02:32 +01:00
MeanSquaredError
9b49afa306
Add is_transaction_active() to all connectors (#550)
* Document the connector API method is_transaction_active()
* Move mysql::connection_base::is_transaction_active() to the other transaction-handling methods.
* Add more tests for mysql::connection::is_transaction_active()
* Add postgresql::connection_base::is_transaction_active()
* Add tests for postgresql::connection_base::is_transaction_active()
* Change the type of the SQLite3 transaction status from transaction_status_type to a boolean flag.
* Add sqlite3::connection_base::is_transaction_active()
* Add tests for sqlite3::connection_base::is_transaction_active()
* When closing a transaction do it in the following order: report (if any), execute SQL command, set transaction active flag to false.
2024-01-05 08:59:42 +01:00
Roland Bock
3474a4fa5d Add missing includes, #548 2023-12-26 08:30:24 +01:00
Roland Bock
6cc2067ef5 Allow alias of single-column select to be used as select column (#542) 2023-11-19 12:57:54 +01:00
fed
7a21ab63ee Fix build on x86 2023-11-16 17:41:39 +00:00
Roland Bock
451e337979 Introduce postgresql::remove_from with optional returning clause (#538) 2023-11-02 07:02:07 +01:00
Roland Bock
9e19911ada Fix compile issue for VS2015.3 (#536) 2023-10-21 09:20:07 +02:00
Stanislav Korolev
7b755b68ad Fix warning for greater_equal operator. 2023-10-14 07:02:10 +00:00
Roland Bock
50aa733fec [mysql] Remove (auto-)reconnect
MySQL 8.0.34 deprecates `MYSQL_OPT_RECONNECT`. As discussed in #530,
this commit is removing library support for (auto-)reconnect.

It is of course still possible to reconnect directly using the native
handle.
2023-10-08 11:34:59 +02:00
Roland Bock
0bddd3c739 Rename head/tail to back/front
_head used to represent the position of the next push_back()
and _tail used to represent the position of front().

This CL renames them to avoid confusion.
2023-10-01 18:35:08 +02:00
Roland Bock
4616450af1 Simplify logic for circular_buffer<T>::set_capacity 2023-10-01 15:10:15 +02:00
Roland Bock
ea9bd9ee32 Add tests for circular buffer 2023-10-01 15:09:53 +02:00
Roland Bock
1b074b7f62 clang-format circular_buffer.h 2023-10-01 10:00:29 +02:00
MeanSquaredError
623b5154d0
Add connection methods is_connected() and ping_server() (#528)
* Replace connection handle method check_connection() with is_connected() and ping_server()

* When a connections is fetched from a pool perform a validity check which can be one of none, passive or ping.

* Add the methods is_connected() and ping_server() to the connection template class.

* Remove unused #include and add mising #include.

* Add tests for the connection methods is_connected() and ping_server().
2023-09-20 06:38:16 +02:00
MeanSquaredError
8d92e7bb81
Add sqlpp::compat::make_unique (#527)
* Add sqlpp::compat::make_unique which calls std::make_unique in C++14 or newer and falls back to a custom implementation in C++11 mode.

* Add tests for sqlpp::compat::make_unique
2023-09-16 09:21:05 +02:00
MeanSquaredError
25bca54ba7
Replace regex-based date/time parsing with manual parser (#520)
* Replace regex-based date/time string parsing with manually written parsing code.

* Add date/time parser tests.
2023-09-07 06:23:44 +02:00
MeanSquaredError
1cd47c77dd
Move method definitions inside corresponding classes (#521)
* Move the method definitions of sqlpp::normal_connection inside the class.
* Move the method definitions of sqlpp::pooled_connection inside the class.
* clang-format include/sqlpp11/connection.h
* clang-format include/sqlpp11/connection_pool.h
2023-09-01 06:19:04 +02:00
MeanSquaredError
348511d078
A couple of minor cleanups in the PostgreSQL connector (#518)
* Replace ()-init with {}-init

* Move the method definitions for sqlpp::postgresql::detail::connection_handle inside the class.
2023-08-23 07:19:06 +02:00
MeanSquaredError
d0dc081625
Unify date/time value parsing in connectors (#517)
* Move the PostgreSQL date/time parsing code to common functions in sqlpp::detail

* Use the common date/time-parsing functions to parse the MySQL date/time results.

* Use regular expressions to parse date/time strings in the SQLite3 connector
2023-08-20 10:39:53 +02:00
MeanSquaredError
fdbfbc345e Replace ()-initialization with {}-initialization in the SQLite3 connector code. 2023-08-19 07:30:13 +00:00
MeanSquaredError
f7ad116ced Change method parameter type "const std::string" -> "const std::string&" 2023-08-17 05:28:16 +00:00
MeanSquaredError
c550dca89e
Cleanup SQLite3 connector code (#514)
* Move the code for sqlpp::sqlite3::detail::prepared_statement_handle_t to include/sqlpp11/sqlite3/detail/prepared_statement_handle.h

* Whitespace

* Move the code for sqlpp::sqlite3::detail::connection_handle to include/sqlpp11/sqlite3/detail/connection_handle.h

* Rename sqlpp::sqlite3::serializer_t -> sqlpp::sqlite3::context_t

* Add const qualifiers to sqlpp::mysql::context_t::escape() and its parameter.

* Change method argument types "const std::string" -> "const std::string&"

* Remove a superfluous function that forwards the call to sqlite3_close().

* Move initialization of sqlpp::sqlite3::detail::prepared_statement_handle_t data members from the constructor into the member initialization list.

* Rename method parameter from CamelCase to snake_case.
2023-08-17 07:26:54 +02:00
MeanSquaredError
4a9da95fda
Use brace-style initialization wherever possible. (#512)
Applied to the PostgreSQL connector.
2023-08-10 15:02:12 +00:00
MeanSquaredError
d800f4d6fa
Cleanup the code of the MySQL connector (#511)
* Move the method definitions for sqlpp::postgresql::detail::statement_handle_t inside the class.

* Move the method definitions for sqlpp::postgresql::detail::prepared_statement_handle_t inside the class.

* Move the method definitions for sqlpp::postgresql::prepared_statement_t inside the class.

* Move the method definitions for sqlpp::postgresql::::Result inside the class.

* Remove superfluous inline specifier from the in-class method definitions of sqlpp::postgresql::Result.

* Remove unused method declaration sqlpp::postgresql::Result::hasError()

* Move the method definitions for sqlpp::postgresql::bind_result_t inside the class.

* Move the method definitions for sqlpp::postgresql::connection_base inside the class.

* Add a comment explaining why sqlpp::postgresql::context_t::escape() is defined out-of-class.

* Remove incorrect comment about forward declaration

* Remove a superfluous function that forwards the call to PQFinish().

* Replace "std::string" parameters with "const std::string&".

* Remove superfluous detail:: namespace qualification.

* Rename class/struct types, variables and functions from CamelCase to snake_case.
2023-08-07 17:37:59 +00:00
MeanSquaredError
c03ac660ee
Use brace-style initialization wherever possible. (#510) 2023-08-07 07:37:29 +02:00
Roland Bock
37739bd2d7 Add missing template parameter
This fixes a compiler error for C++11/14
2023-08-06 10:18:59 +02:00
MeanSquaredError
490259ee69
Cleanup the code of the MySQL connector (#509)
* Move the code for sqlpp::mysql::detail::connection_handle_t to include/sqlpp11/mysql/detail/connection_handle.h
* Move the code for sqlpp::mysql::detail::prepared_statement_handle_t to include/sqlpp11/mysql/detail/prepared_statement_handle.h
* Move the code for sqlpp::mysql::detail::result_handle to include/sqlpp11/mysql/detail/result_handle.h
* Rename sqlpp::mysql::detail::connection_handle_t -> sqlpp::mysql::detail::connection_handle
* Rename sqlpp::mysql::serializer_t -> sqlpp::mysql::context_t
* Add const qualifiers to sqlpp::mysql::context_t::escape() and its parameter.
* Rename class/struct types, variables and functions from CamelCase to snake_case.
* Remove a superfluous function that forwards the call to mysql_close().
2023-08-05 09:18:51 +02:00
MeanSquaredError
a085d730c9
Replace include guards with "#pragma once" in all header files and in the database model generator scripts. (#506) 2023-07-25 07:00:05 +02:00
MeanSquaredError
4295c29e9a
Fix serialization of PostgreSQL time data types (#504)
* Use a non-UTC timezone when testing the PostgreSQL timezone support.
* Fix serialization of time of day values for PostgreSQL
* Fix serialization of PostgreSQL values for "timestamp with time zone" and "time with time zone" fields.
2023-07-24 06:40:18 +02:00
MeanSquaredError
4a1ed2c02e
Fix serialization of time points for MySQL. (#503) 2023-07-23 10:40:27 +02:00
MeanSquaredError
dff8c23b22
Connection pools (#499)
Add support for connection pooling

* Add support for connection pooling to the core code.
* Add support for PostgreSQL connection pooling with tests.
* Add support for SQLite3 connection pooling with tests.
* Add support for MySQL connection pooling with tests.
2023-07-17 06:14:23 +02:00
Roland Bock
a50d719364 Fix brace initialization, #498 2023-06-30 06:39:46 +02:00
MeanSquaredError
26280d2678
gcc warnings (#496)
* Enable std::move() by using std::string instead of const std::string&

* Fix dangling references.
2023-06-28 06:32:39 +02:00
Carel
eac9a6e5e3
Const connection config (#494)
- The postgres connection does not change the connection_config thus passing it as const.
- Implies 'thread safety' when using the same config for multiple connections

Co-authored-by: Carel Combrink <carel.combrink@vastech.co.za>
2023-06-20 06:28:22 +02:00
MeanSquaredError
a72b172a52
Treat PostgreSQL time values as being in UTC time zone (#487)
* When inserting values into "timestamp with time zone" fields treat the value as being in the UTC time zone.

* Simplify parsing of PostgreSQL date/time responses by using regular expressions. Always convert response times with time zone to UTC.

* Add tests which check if timestamp and date fields are treated as having a UTC time zone.

* Clarify the test comments.
2023-06-16 06:57:19 +02:00
Matthijs Möhlmann
38aba217d4 std::string_view should also be assignable in prepared statements 2023-04-03 06:16:57 +02:00
Bernd Lörwald
9412851408
#471 serializers: ensure float precision (#472)
* value: add missing includes
* mysql, sqlite3: use explicitly *out* stringstreams for serialization
* postgresql: fix: use max_digits10 instead of digits10
* detail: add float_safe_ostringstream, ensuring floats are serialized with enough precision
* mysql, postgresql, sqlite3, tests: fix: set float-precision for all streams
* run clang-format on changed files
* inline remove_cvref.h
* replace unspecific "wrapper" with concrete type name
* tests: split connector specific tests out of serialize/Float
2023-02-18 08:10:50 +01:00
Roland Bock
64d16bfee0 Cleanup parens for ANY and SOME 2023-02-05 09:31:30 +01:00
Roland Bock
0731a8597d Cleanup parens for EXISTS 2023-02-04 10:21:54 +01:00
Roland Bock
2d3967a0b3 Cleanup braces for IS_NULL and IS NOT NULL 2023-02-04 10:12:55 +01:00
Roland Bock
1c4f1f61c8 Allow TRIM to be used with sub selects 2023-02-04 09:05:04 +01:00
Roland Bock
3fba3e721e Add UPPER and LOWER
This is replacing and extending #456.
2023-02-04 08:57:17 +01:00
Roland Bock
82758a2046 Add missing braces to aggregatedfunctions with sub select #469
Also allow MIN and MAX to be used with DISTINCT.
2023-01-29 14:39:07 +01:00
Roland Bock
673b07361b Add missing braces to SUM with sub select #469 2023-01-29 12:57:02 +01:00
Roland Bock
743d39c0c6 Rename requires_braces to requires_parens
This fixes a typical German mistake :-)
2023-01-29 11:55:58 +01:00
Moritz Wirger
42bd3cc79b Fix include for iso646 missing for MSVC 2022-12-10 09:37:56 +01:00
Roland Bock
57077cd32b Add standalone insert_columns function (#76)
This allows for multi-row INSERT OR IGNORE
2022-06-06 10:15:28 +02:00
Roland Bock
f5be4095ae Allow parameter in having clause, see #443
Disallow mixing aggregate and non-aggregate columns in select, too.
2022-05-22 15:05:58 +02:00
Roland Bock
1d5caca523 Allow value_or_null to be assigned to parameters (#435) 2022-04-02 08:27:38 +02:00
Mike Neilson
6477f09125 Added additional exception class.
Handles the case of user defined exception in pl/pgsql to it can be reported
back to the calling application.
2022-03-11 07:47:22 +01:00
Roland Bock
b965b2a1df Fix warnings (#422) 2022-03-04 07:49:05 +01:00
Jürgen Hunold
f7f2060c44 Add support for TIME columns in postgresql 2022-02-08 18:24:15 +01:00
Roland Bock
b8aed2af55 Address conversion warnings and fix UAF bug in test 2022-01-14 07:39:11 +01:00
Roland Bock
ccc75eafc7 Remove obsolete pointer indirection and some warnings 2022-01-12 07:06:06 +01:00
Roland Bock
d6aef0fa9b Remove obsolete pointer indirection, fix warnings and a leak
Leak: The sqlite3 connection handle destructor was
accidentally turned into a default constructor during the
migration of repositories.

Replaced the sqlite3 raw pointer with a unique_ptr to prevent
this kind of accident.
2022-01-11 07:35:20 +01:00
Roland Bock
3be4893bfe Remove obsolete pointer indirection in mysql connector 2022-01-09 09:12:23 +01:00
Roland Bock
40845e6b09 Remove incomplete connection pool
Porting the connection pool from sqlpp17 seems more promising, see #397
2022-01-08 19:02:29 +01:00
Roland Bock
181cc5fb04 Fix compiler warnings. 2021-12-11 19:53:35 +01:00
Andreas Sommer
36d3d30254 Support MySQL connect timeout option 2021-12-10 10:57:06 +01:00
Andreas Sommer
c37c8d36c5 Add missing includes 2021-12-10 10:49:37 +01:00