Add -[FMResultSet typeInformation] to mitigate missing type information in FMResultSet. #142

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

jjthrash commented May 3, 2013

The FMResultSet API destroys column information in the database,
particularly in the float vs integer case. As a result, the
-[FMResultSet resultDictionary] API smashes both ints and floats
together as NSNumber*, making it difficult to introspect.

This API allows a minimal amount of introspection to work around
this problem.

In my case, I needed this API to deal with a fairly run-of-the-mill floating point formatting issue, since SQLite doesn't have actual decimal types.

@jjthrash jjthrash Add -[FMResultSet columnTypeForColumn(Index):]
The FMResultSet API destroys column information in the database,
particularly in the float vs integer case. As a result, the
-[FMResultSet resultDictionary] API smashes both ints and floats
together as NSNumber*, making it difficult to introspect.

This API allows a minimal amount of introspection to work around
this problem.
6756f65

ccgus commented on 6756f65 May 24, 2013

Why not just use SQLITE_INTEGER and such?

Owner

jjthrash replied May 24, 2013

Not sure what you're asking. The point is that if I have a floating point column, I want to know it's floating point so I can handle it differently from integers. As it is now, both integers and floating points are returned as NSNumber. Is there another way around what I'm doing?

Obviously for columns I already know about, I have the information I need. But I have a few columns that I treat generically and it seems a shame not to use info that's built into the DB already.

Well, my question was why are there some new enums, when SQLite already provides some for us and a method to get at the data. But I've got another question - are you using objectForColumnIndex? You can find out how your number was created (via float or int) via: [NSNumber objCType] as described here: http://www.cocoabuilder.com/archive/cocoa/289696-how-tell-tell-if-an-nsnumber-was-initialized-from-float-or-int.html

Does that make sense? I guess I don't see the need for this patch when there's already two different ways to get at this data :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment