Hello again, 2012/3/9 Ricardo Muñoz Fernández <[email protected]>: > Hello! i've found a extrange behaviour related to column names and > binding by name. You can find the code attached to this mail. > I'm using postgresql backend and soci lib compiled from sourceforge git repo: > > ricardo@bugge:~/devel/git/soci(master)$ git show > commit 631977adad434bcbdf0b8ee30314fa886757e4b0 > Merge: 901e1ba 6e45bdb > Author: Mateusz Loskot <[email protected]> > Date: Sat Feb 25 09:22:10 2012 -0800 > > I have a table with 4 columns: id, firstName, lastName, idcard and > streeet. When i try to update a row with: > > st = (sql.prepare << "UPDATE persons SET firstName = :firstName," > " lastName = :lastName, idcard = :idcard, street = :street" > " WHERE id = :id", > use(p)); > > And execute the code i get an error: "Error: Missing use element for > bind by name (id)" > > If i change all occurrences of "idcard" by "card" in the code, it works. > > Its a bug or i'm doing something wrong?
I was debugging soci to understand what happens under the hood, and i found the reason of described behaviour on statement_impl::bind(values & values) (core/statement.cpp). On line 101: query_.find(placeholder) returns the first occurrence of ":id", that match with :idcard word on the query, and not with the desired match on WHERE clause: UPDATE persons SET firstName = :firstName, lastName = :lastName, idcard = :idcard, street = :street WHERE id = :id So thats the reason of changing idcard by card, solves the problem. I've tried to fix it using a while loop (patch attached), and it founds all placeholders but i get a segmentation fault later. It's the first time that i get into soci's code so i feel a little bit lost. If any developer can give some guidance i will try to fix it (if you consider it a bug), for the moment, I workaround it changing my naming scheme to avoid multiple matches. HTH, regards -- Ricardo Muñoz Fernández Warp Networks S.L. - http://www.warp.es Zentyal - http://www.zentyal.com ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Soci-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/soci-users
