Giter VIP home page Giter VIP logo

Comments (2)

djthorpe avatar djthorpe commented on August 15, 2024

Hi! Sorry for the delay in rpelying to you. I'll get on this at the weekend
and put the fixes in place. I've really only just begun the iOS side of
things, so it would be great to have someone else test and/or commit. Feel
free to send along some pull requests.

On 21 November 2013 16:50, erisler-myntpartners [email protected]:

Great work building this framework. I think I've found a logic error that
trips an assert.

I'm running Xcode5,iOS7SDK, I added your project as a sub-project to mine
and updated your project with the most recent version of the
iOS-Universal-Framework.

Everything builds and connects to my remote postgesql (osx Mavericks,
postgres 92 that is part of the system) db just fine. Here is the issue I'm
encountering:

When I run a query against a table that contains rows with empty character
varying values (i.e. zero length strings, NOT null values) the
-_tupleForRow:column: method's NSParameterAssert(size) assert trips when I
call the -fetchRowAsArray method. Your code:

-(NSObject* )

_tupleForRow:(NSUInteger)r column:(NSUInteger)c { // check for null
if(PQgetisnull(_result,(int)r,(int)c)) {
return [NSNull null];
}
// get bytes, length
const void* bytes = PQgetvalue(
result,(int)r,(int)c); NSUInteger size = PQgetlength(
result,(int)r,(int)c);
NSParameterAssert(bytes);
NSParameterAssert(size);

switch(_format) {
case PGClientTupleFormatText:
return pgdata_text2obj(PQftype(_result,(int)c),bytes,size,_encoding);
case PGClientTupleFormatBinary:
return pgdata_bin2obj(PQftype(_result,(int)c),bytes,size,_encoding);
default:
return nil;
}

}

The if(PQgetisnull(_result,(int)r,(int)c)) returns false on empty string
and zeros according to the libpq library documentation but the PQgetlength
will return the string length for text values and the byte length for
binary values. So, on empty string fields this returns 0 and trips your
assert.

My fix was to comment out the NSParameterAssert(size); assert. And in the
pgdata_bin2obj and pgdata_text2obj functions I changed the assert from
assert(oid && bytes && size); to assert(oid && bytes);

Can you kindly check if all this makes sense?


Reply to this email directly or view it on GitHubhttps://github.com//issues/6
.

from postgresql-kit.

ericrisler avatar ericrisler commented on August 15, 2024

Pull request created.

from postgresql-kit.

Related Issues (15)

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.