Bug 352631 - Add support for typical scalar SQL functions
Summary: Add support for typical scalar SQL functions
Status: CLOSED FIXED
Alias: None
Product: KEXI
Classification: Applications
Component: KexiDB (show other bugs)
Version: 2.9.7
Platform: unspecified All
: NOR wishlist
Target Milestone: 2.9.8
Assignee: Jarosław Staniek
URL: https://community.kde.org/Kexi/Plugin...
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-12 22:06 UTC by Jarosław Staniek
Modified: 2015-09-29 19:14 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.9.8
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jarosław Staniek 2015-09-12 22:06:17 UTC
Add support for typical scalar SQL functions returning a single value based on arguments.

https://community.kde.org/Kexi/Plugins/Queries/SQL_Functions#Typical_Scalar_Functions


Reproducible: Always
Comment 1 Jarosław Staniek 2015-09-12 22:26:23 UTC
Git commit d09d012b470df192214524326a3b8444c51daac6 by Jaroslaw Staniek.
Committed on 12/09/2015 at 22:22.
Pushed by staniek into branch 'kexi-functions-352631-staniek'.

calligradb: Add support for 22 typical scalar SQL functions

With minor exceptions these functions now work with SQLite, MySQL, PostgreSQL:
*abs(X)
*ceiling(X)
*char(X1,X2,...,XN)
*coalesce(X,Y,...)
*floor(X)
*greatest(X,Y,...) & alias max(X,Y,...)
*hex(X)
*ifnull(X,Y)
*instr(X,Y)
*least(X,Y,...) & alias min(X,Y,...)
*length(X)
*lower(X)
*ltrim(X) & ltrim(X,Y)
*nullif(X,Y)
*random() & random(X,Y)
*replace(X,Y,Z)
*round(X) & round(X,Y)
*rtrim(X) & rtrim(X,Y)
*soundex(X)
*trim(X) & trim(X,Y)
*unicode(X)
*upper(X)

In many cases substitute functions are used to make the result work in a portable way.

The implementation of function parser supports:
* checking number of arguments
* checking types of arguments, sometimes "any number" or "any text or BLOB"
* checking compatibility of arguments in function
* checking relation of value of arguments in function, e.g. value of the first argument smaller than second's
* checking NULL arguments in function; then most often the result is NULL
* argument overloading or optional arguments, e.g. round(X) and round(X,Y)
* displaying of human-readable error messages when the above constraints are not met, for example "Three arguments required" or "Function does not accept any arguments"
* easy extensibility using just a few lines of code

Note: no extra i18n added; will be added in a KDb port

M  +21   -0    kexi/kexidb/drivers/mysql/mysqldriver.cpp
M  +20   -0    kexi/kexidb/drivers/mysql/mysqldriver.h
M  +5    -0    kexi/kexidb/drivers/pqxx/pqxxconnection.cpp
M  +34   -0    kexi/kexidb/drivers/pqxx/pqxxdriver.cpp
M  +29   -0    kexi/kexidb/drivers/pqxx/pqxxdriver.h
M  +54   -1    libs/db/driver.cpp
M  +50   -1    libs/db/driver.h
M  +5    -1    libs/db/driver_p.h
M  +1    -0    libs/db/drivers/sqlite/CMakeLists.txt
M  +6    -1    libs/db/drivers/sqlite/sqliteconnection.cpp
M  +1    -1    libs/db/drivers/sqlite/sqliteconnection.h
M  +64   -1    libs/db/drivers/sqlite/sqlitedriver.cpp
M  +31   -1    libs/db/drivers/sqlite/sqlitedriver.h
A  +114  -0    libs/db/drivers/sqlite/sqlitefunctions.cpp     [License: Public Domain LGPL (v2+)]
A  +30   -0    libs/db/drivers/sqlite/sqlitefunctions.h     [License: LGPL (v2+)]
M  +983  -55   libs/db/expression.cpp
M  +18   -0    libs/db/expression.h

http://commits.kde.org/calligra/d09d012b470df192214524326a3b8444c51daac6