Giter Club home page Giter Club logo

Comments (4)

rbock avatar rbock commented on August 24, 2024

Actually, I don't think this would be a good idea.

The parameters take values which are to be used with bind. If you don't have this value (insert yields the last row id), you can query it:

 db(
    select(
        sqlpp::verbatim<sqlpp::integer>("last_insert_rowid()")
        .as(tab.alpha)))
 .front().alpha

But I don't think it makes sense expect the library to perform that part for you.

I still made a change for this: "where" is now not mandatory for such queries anymore (f6ae27b)

from sqlpp11.

dirkvdb avatar dirkvdb commented on August 24, 2024

I agree that the last_insert_rowid might not be the best use case to support this feature. I was also able to solve it in a different way.

But the verbatim feature is there to support the things that just fall outside of the scope of the library. These corner cases where you need to use some db specific feature. It would be a shame if the user would loose the ability to prepare the statement or even worse would have to revert to the low level api for these scenarios.

Users should be aware that when they take the verbatim route the sqlpp11 library will just pass it on without too many checks, but that's ok.

Currently I have no use case anymore for the feature myself anymore, but I bet someone will ever find the need to do this.

Losing the obligatory where(true) is great though! :-)

from sqlpp11.

rbock avatar rbock commented on August 24, 2024

On 2014-08-17 22:55, dirkvdb wrote:

I agree that the last_insert_rowid might not be the best use case to
support this feature. I was also able to solve it in a different way.

I assume something along the lines of

auto id = db(insert_into(tab).set(name="xx"));

But the verbatim feature is there to support the things that just fall
outside of the scope of the library. These corner cases where you need
to use some db specific feature.

Right.

It would be a shame if the user would loose the ability to prepare the
statement or even worse would have to revert to the low level api for
these scenarios.

It would certainly be possible to add a convenience function for the
line I posted earlier. This way, the parameters would still take values
(or NULL) but you could call special functions nonetheless...

Users should be aware that when they take the verbatim route the
sqlpp11 library will just pass it on without too many checks, but
that's ok.

Currently I have no use case anymore for the feature myself anymore,
but I bet someone will ever find the need to do this.

You're probably right :-)

Losing the obligatory where(true) is great though! :-)

:-)

from sqlpp11.

rbock avatar rbock commented on August 24, 2024

On 2014-08-17 22:55, dirkvdb wrote:

I agree that the last_insert_rowid might not be the best use case to
support this feature. I was also able to solve it in a different way.

But the verbatim feature is there to support the things that just fall
outside of the scope of the library. These corner cases where you need
to use some db specific feature. It would be a shame if the user would
loose the ability to prepare the statement or even worse would have to
revert to the low level api for these scenarios.

Users should be aware that when they take the verbatim route the
sqlpp11 library will just pass it on without too many checks, but
that's ok.

Currently I have no use case anymore for the feature myself anymore,
but I bet someone will ever find the need to do this.

The develop branch now has a function called eval. It takes an
expression or string X and returns the result of

select X

An example can be found here:
https://github.com/rbock/sqlpp11-connector-sqlite3/blob/develop/tests/SampleTest.cpp

ps.params.alpha = sqlpp::evalsqlpp::integer(db, "last_insert_rowid()");

from sqlpp11.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.