It's ok with me.

On 09/07/2015 20:27, Tommi Mäkitalo wrote:
The iterator version is already there.

And yes, I mean to remove any .set with containers. Users should use the iterator version always.

So it would be ok to you to remove the container version?

I really do not like breaking compatibility but here I feel, that it is better to do it since we already have one irritating case, which could be solved with it.

Am 09.07.2015 um 20:05 schrieb Jouven:
I use it. I don't know if there are a better ways though.
E.g.
query string --> "select * from sometable where idField in (%ids)"
then:
tntdb::SqlBuilder sqlBuilderObj(query string).extendParam("ids", container.size()));
then:
tntdb::Connection conn(connectionString);
auto result(conn.prepare(sqlBuilderObj).set("ids",container).select());

I don't know if you mean removing any .set that accepts containers so everyone has to do the loops manually or only the
result.set("bar", foobar)
version. And allowing this one:
result.set("bar", foobar.cbegin(), foobar.cend());
But yeah, setting container objects isn't trivial, like setting a string or int value, inexperienced users might just try adding the :placeholder and doing set of the container object thinking it will magically work (It won't). Anyhow, I would want to have the iterators version at least if the only alternative is doing loops and setting the values individually.

Regards,
Joan
On 09/07/2015 18:38, Tommi Mäkitalo wrote:
Hi,

the problem is, that there is already a similar operator for std::set<T> in the tntdb namespace, which is prefered. So your operator is not used at all.

The other operator fills a list of host variables. Calling
result.set("bar", foobar)
results in
result.set("bar0", "FOO");
result.set("bar1", "BAR");
When thinking again I'm not sure, if that was such a good idea to define it that way. The same is achived by:
result.set("bar", foobar.begin(), foobar.end());
I think I should really remove those operators for containers. It is irritating.

I guess no one has used that feature and those who have, will get a compile error, so that nothing unexpected will happen, when I remove those.

Any opinions?


Tommi


Am 07.07.2015 um 12:29 schrieb Matthias Kraß:

Hi All,

I’ve tried to overload the operator described in http://www.tntnet.org/howto/tntdb.html at the part “Using own types”, so that I can write a std::set<std::string> in a mysql Database. Therefore I implemented this:

void operator <<(tntdb::Hostvar& hv, const std::set<std::string>& lists) {

        std::ostringstream s;

        for(auto element: lists) {

            s << element << ";";

        }

       hv.set(s.str());

    }

This should define how a set should be written in the Database. I’ve tested it with this example:

       std::set<std::string>  foobar ={"FOO","BAR"};

        tntdb::Statement result = DB->connection.prepare(

            "CREATE TABLE IF NOT EXISTS foo(bar TEXT)");

        result.execute();

        result = DB->connection.prepare(

            "INSERT INTO foo(bar) values (:bar)");

        result.set("bar",foobar);

        result.execute();

So after this the table in the Database should look like :

+-------------+

| bar              |

+-------------+

| FOO;BAR; |

+-------------+

But the database entry looks like:

+-------------+

| bar              |

+-------------+

| NULL          |

+-------------+

Can somebody reproduce this misbehaviour?

Kind regards,

Matthias Kraß



------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/


_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general



------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/


_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general



------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/


_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general



------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/


_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to