Giter Club home page Giter Club logo

Comments (13)

rbock avatar rbock commented on July 21, 2024

Not yet. Do any of these sub statements compile?

tab.colDayPoint = parameter(tab.colDayPoint;

update(tab)..set(tab.colDayPoint = parameter(tab.colDayPoint);

from sqlpp11-connector-mysql.

juandent avatar juandent commented on July 21, 2024

Yes, these compile fine:

tab.colDayPoint = parameter(tab.colDayPoint);

update(tab).set(tab.colDayPoint = parameter(tab.colDayPoint));

from sqlpp11-connector-mysql.

juandent avatar juandent commented on July 21, 2024

Hi Roland,

Actually there is more that may help you: if I remove the unconditionally() like so:

    auto prepared_update = db.prepare(
        update(tab)
        .set(tab.colDayPoint = parameter(tab.colDayPoint)));           // .unconditionally());

I get a worst error:
error C3313: 'prepared_update': variable cannot have the type 'void'

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Hi Juan,

Thanks. I assume that is not the complete error message though, is it? There should be some output from a static_assert, too.

Anyway, please try again with the current sqlpp11 develop branch. I am pretty sure I fixed your original query.

Best,

Roland

from sqlpp11-connector-mysql.

juandent avatar juandent commented on July 21, 2024

Hi Roland,

No, there is no more error output from any static_assert. I tried with the current sqlpp11 develop branch to no avail.

I tried something that removed all compile errors, but I have a feeling this does not solve the problem (probably a "false" fix - please check it to see if it makes semantics sense).

It has to do with removing an & in the static_cast in line 65 of parameter_list.h like so:

    template <typename Target, size_t... Is>
    void _bind_impl(Target& target, const detail::index_sequence<Is...>&) const
    {
      using swallow = int[];  // see interpret_tuple.h
      (void)swallow{0, (
          static_cast<typename std::tuple_element<Is, const _member_tuple_t>::type/*&*/>(*this)()._bind(target, Is), 0)...};
    }

This code throws an exception:

    auto prepared_update = db.prepare(
        update(tab)
            .set(tab.colDayPoint = parameter(tab.colDayPoint), tab.colTimePoint = parameter(tab.colTimePoint))
            .unconditionally());

    prepared_update.params.colDayPoint = today;
    prepared_update.params.colTimePoint = now;
    std::cout << "---- running prepared update ----" << std::endl;
    db(prepared_update);
    std::cout << "---- finished prepared update ----" << std::endl;
    for (const auto& row : db(select(all_of(tab)).from(tab).unconditionally()))
    {
      require_equal(__LINE__, row.colDayPoint.value(), today);
      require_equal(__LINE__, row.colTimePoint.value(), now);
    }
  }
  catch (const std::exception& e)
  {
    std::cerr << "Exception: " << e.what() << std::endl;
    return 1;
  }

the output is:

---- running prepared update ----
MySQL debug: binding date parameter at index: 0, being not null
MySQL debug: binding date_time parameter at index: 1, being not null
MySQL debug: Executing prepared_statement
Exception: MySQL error: Could not execute prepared statement: Incorrect date value: '' for column 'col_day_point' at row 1

So, something is fishy with the prepared statement....

Regards,
Juan

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Your 'fix' leads to parameter values not being set.

Please try again with the latest develop version of sqlpp11. I fixed the problem. It compiles on appveyor with MSVC 2015 Update 2. There is a problem with the linker now, but that is a problem of the setup on appveyor.

Best,

Roland

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

I am testing appveyor on this branch here: feature/appveyor_integration

from sqlpp11-connector-mysql.

juandent avatar juandent commented on July 21, 2024

Yes Roland with latest sqlpp11 from develop branch it now compiles without errors BUT the behavior is as before -- the parameter values are not being set for the prepared update as we can see in the output:

---- running prepared update ----
MySQL debug: binding date parameter at index: 0, being not null
MySQL debug: binding date_time parameter at index: 1, being not null
MySQL debug: Executing prepared_statement
Exception: MySQL error: Could not execute prepared statement: Incorrect date value: '' for column 'col_day_point' at row 1

What could be going on? I am not that familiar yet with your code ... I have been taking time out but nothing too committed.

Regards,
Juan

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

BTW, I just confirmed the compile error you reported if you omit the unconditionally(). It is so annoying that compilers behave so differently. Every other compiler reports a static_assert...

Since I cannot run the tests on appveyor yet, in file src/prepared_statement.cpp, functions _bind_date_parameter and _bind_date_time_parameter can you please add this line:

std::cerr << "bound values: " << bound_time.year << '-' << bound_time.month << '-' << bound_time.day << 'T' << bound_time.hour << ':' << bound_time.minute << ':' << bound_time.second << std::endl;

at the end of the if (not is_null) block.

Thanks,

Roland

from sqlpp11-connector-mysql.

juandent avatar juandent commented on July 21, 2024

Hi Roland,
I just had the chance to add the code you asked me and when I execute the prepared update I get this error message:
---- running prepared update ----
MySQL debug: binding date parameter at index: 0, being not null
bound values: 2016-5-15T0:0:0
MySQL debug: binding date_time parameter at index: 1, being not null
bound values: 2016-5-15T3:5:27
MySQL debug: Executing prepared_statement
Exception: MySQL error: Could not execute prepared statement: Incorrect date value: '' for column 'col_day_point' at row 1

So is this bit more of information helpful?

Regards,
Juan

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Hi Juan,

Thanks for testing. It is very helpful in that it assures that reasonable values were used.

Yikes! I think I just found the bug. Thought I fixed that long ago...

Please try again with the current develop of sqlpp11-connector-mysql

Best,

Roland

from sqlpp11-connector-mysql.

juandent avatar juandent commented on July 21, 2024

Hi Roland,

Just tried it: it works!!! Congratulations :-)

Regards,
Juan

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Hi Juan,

cool, thanks for the support!

Best,

Roland

from sqlpp11-connector-mysql.

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.