Skip to content
Snippets Groups Projects
Commit 2753c8e8 authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

Do not fall back to untyped mode if typed mode isn't available.

There'd be a risk of incompatibility if a db backend adds typed mode later.
parent 3032b456
No related branches found
No related tags found
No related merge requests found
...@@ -608,12 +608,16 @@ array(mapping(string:string)) query(object|string q, ...@@ -608,12 +608,16 @@ array(mapping(string:string)) query(object|string q,
//! result (eg @tt{INSERT@} or similar). //! result (eg @tt{INSERT@} or similar).
//! @endmixed //! @endmixed
//! //!
//! @note
//! Typed mode is not supported by all sql databases. If not
//! supported, an error is thrown.
//!
//! @seealso //! @seealso
//! @[query], @[big_typed_query] //! @[query], @[big_typed_query]
array(mapping(string:mixed)) typed_query(object|string q, mixed ... extraargs) array(mapping(string:mixed)) typed_query(object|string q, mixed ... extraargs)
{ {
if (!master_sql->big_typed_query) if (!master_sql->big_typed_query)
return query(q, @extraargs); // FIXME: Throw error instead? ERROR ("Typed mode not supported by the backend %O.\n", master_sql);
if (sizeof(extraargs)) { if (sizeof(extraargs)) {
mapping(string|int:mixed) bindings; mapping(string|int:mixed) bindings;
...@@ -701,9 +705,8 @@ int|object big_query(object|string q, mixed ... extraargs) ...@@ -701,9 +705,8 @@ int|object big_query(object|string q, mixed ... extraargs)
//! or similar). //! or similar).
//! //!
//! @note //! @note
//! This interface is not supported by all sql databases. //! Typed mode is not supported by all sql databases. If not
//! If not supported, the result will currently be the same //! supported, an error is thrown.
//! as if @[big_query()] would be called.
//! //!
//! @note //! @note
//! Despite the name, this function is not only useful for "big" //! Despite the name, this function is not only useful for "big"
...@@ -714,7 +717,8 @@ int|object big_query(object|string q, mixed ... extraargs) ...@@ -714,7 +717,8 @@ int|object big_query(object|string q, mixed ... extraargs)
//! @[query], @[typed_query], @[big_query], @[streaming_query] //! @[query], @[typed_query], @[big_query], @[streaming_query]
int|object big_typed_query(object|string q, mixed ... extraargs) int|object big_typed_query(object|string q, mixed ... extraargs)
{ {
if (!master_sql->big_typed_query) return big_query(q, @extraargs); if (!master_sql->big_typed_query)
ERROR ("Typed mode not supported by the backend %O.\n", master_sql);
mapping(string|int:mixed) bindings; mapping(string|int:mixed) bindings;
...@@ -795,8 +799,7 @@ int|object streaming_query(object|string q, mixed ... extraargs) ...@@ -795,8 +799,7 @@ int|object streaming_query(object|string q, mixed ... extraargs)
//! @note //! @note
//! Neither streaming operation nor typed results are supported //! Neither streaming operation nor typed results are supported
//! by all sql databases. If not supported, this function will //! by all sql databases. If not supported, this function will
//! fall back to calling @[big_typed_query()] (which in turn //! fall back to calling @[big_typed_query()].
//! may fall back even further).
//! //!
//! @seealso //! @seealso
//! @[streaming_query], @[big_typed_query] //! @[streaming_query], @[big_typed_query]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment