Comments (15)
Hi,
I haven't thought about this before, but it certainly sounds like a reasonable idea. Could you give it a try?
Best,
Roland
from sqlpp11.
I'll try,but I'm sure I'll need help :)
Br, Z.
from sqlpp11.
OK, looking forward to it :-)
from sqlpp11.
Hi.
I've started creating this script for postgres database. First thing that I have done is a SQL query to get all aggregate functions from database ( query with output avalible at https://gist.github.com/cszawisza/c8a8456396a87a5db012 )
As you can see, the list contains all functions with overloads. So basing on this output, script can deduce what kind of input/output arguments pairs can be used in those functions, and probably create a overloaded list in C++ code as well, but... Is this really useful? or should the script create templates with only basic type checking(is numeric, float, or text) instead?
And what about normal functions? I find only type for "aggregate_function" and not for "normal" one.
Br, Z.
from sqlpp11.
Hi,
nice script :-)
I would create one template per function and use basic type checking. And you do not need to replace the aggregate_function node. The aggregate_function is basically just a tag to detect nested aggregates (which are not allowed).
Best,
Roland
from sqlpp11.
Hi!
I edited my sql script a bit, it's available at http://sqlfiddle.com/#!15/31586/4/0 now it prints a agregated inputs and outputs off all functions with 'appropriate' argument types. Unfortunately it drops information about strings so, to mark multiple arg functions, I add a && characters between arguments.
e.g.
fun1(A); fun1(B) -> A,B
fun2( A, B ), fun2(A,C) -> A && B, A && C
Output from query is parsed by python script which decides what kind of arguments are used in functions, and so:
No arg -> void
boolean -> boolean
text (and date etc.) -> text
if function has int and real I take the "bigger" type ( bool < int < real )
if function takes numeric and text type then is 'anyelement' type
and output generated from query is avalible at https://paste.kde.org/phszwbqam
In this table I think I've got most of the needed information to create a function template.
Name of function
Type of function (aggregate, normal or window)
Information if function returns the same type as argument type.
Return type
Input types and overloads
Is there any other information that can be useful to me?
from sqlpp11.
Hi,
Looks good! Sounds like you have all information you need to produce sqlpp11-compatible template struct and functions with that.
The devil will be in the detail, I guess :-)
Best,
Roland
from sqlpp11.
Hi!
I have not so much experience in C++ template meta programming, therefore I don't clearly understand your library, is there any chance that you provide me a commented version of one of your function?
What Is most interesting for me is how to handle functions with multiple inputs.
from sqlpp11.
Hi,
I just updated the concat method and added a free function. It is not in the master yet, but in develop:
https://github.com/rbock/sqlpp11/blob/develop/include/sqlpp11/concat.h
If you take a closer look and compare it to other functions, e.g. max, you will realize that most of the code is actually boilerplate (adding value-types and names, or checking input types).
Don't worry, it is not nearly as hard as might look at first glance.
I can try to prepare some documentation later (probably not before the weekend). It would help if you had concrete questions, or a first function you tried to assemble yourself.
Best,
Roland
from sqlpp11.
HI!
I tried to write some function generator code, but I stuck with some questions. I noticed that structure of functions (max, concat, avg) are different.
Max: template
Avg: template<typename Flag, typename Expr>
Concat: template<typename... Args>
So my first pair of questions is
shouldn't Max has a "typename flag" argument?
If aggregate functions are treated all the same, how to read "flag" argument in concat function?
from sqlpp11.
Hi,
Functions like avg have an optional flag DISTINCT. This does not really make a difference for max or min, which is why I did not code it. But it would be more consistent to add flag to max and min. Good catch!
Not sure why you would want a flag for concat?
from sqlpp11.
I have no need for this flag in concat, the only reason is why I'm asking is to create as many common code for all functions as possible, so even if this flag is not used it can be present in the definition.
My main idea is to define all functions as variadic templates, and check the number of arguments in static_aserts in constructor just like in concat, but then i need Flags :)
from sqlpp11.
Personally, I would not try too hard to find one pattern that fits all. To turn strictly unary or binary functions into variadic templates and adding a parameter just for the sake of having the same template parameter list (and then preventing its use with static_assert) sounds a bit strange to me.
That being said, I would still try to find as few groups of similar functions as possible :-)
from sqlpp11.
When I was writing the generator I discovered that for me, now, it is a lot easier to create function code by hand then to create a parser for that. Due to this I decided to stop developing it by now, and try once again, when I'll get get familiar with your lib and c++ templates.
Sorry for the trouble, and thanks for help.
Br, Z.
from sqlpp11.
No worries. Once you feel more comfortable with the whole thing and want to give it another try, just let me know.
Best,
Roland
from sqlpp11.
Related Issues (20)
- Length of the blob received by "select" HOT 2
- Datetime column breaking insertions into database HOT 9
- sqlpp/connection_pool.h: pooled_connection is inaccessable HOT 1
- SQLite3 connection pool error using HOT 4
- Support for pragma tables HOT 1
- sqlite3_step return code 5 with connection pool HOT 2
- how to get a column by string? HOT 2
- how can I use a in where condition,I always get an error? HOT 4
- mingw64, vcpkg, CMake, Project installation cannot find mariadb ? HOT 5
- sqlite connector: execute() silently ignores statements after the first one HOT 7
- how to use binary equal in where HOT 2
- Is there any opentracing support in sqlpp,like jaeger?Will it be supported in the future? HOT 1
- how to fix update exception? HOT 23
- How to retrieve the row count of a query result? HOT 6
- mysql does not seem to support the TIME type HOT 4
- Multiple table query error HOT 3
- Mysql prepared_statement.h missing _bind_time_of_day_parameter function HOT 3
- How do I get record with count of references from one to many? HOT 4
- Handling of `::sqlpp::tag::enforce_null_result_treatment` does not seem to be implemented, NULL documentation is erroneous HOT 11
- scripts/sqlite2cpp.py requires insert of nullable column HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlpp11.