Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoincrement on long #22

Closed
jbarwick opened this issue Dec 4, 2013 · 6 comments
Closed

autoincrement on long #22

jbarwick opened this issue Dec 4, 2013 · 6 comments

Comments

@jbarwick
Copy link

jbarwick commented Dec 4, 2013

I'm a newbie to SQLite. So please forgive. But I did receive this error:

Exception in thread "main" java.lang.IllegalArgumentException: Field "eventId" | is_autoincrement can only be used on an integer type field
at com.foxykeep.cpcodegenerator.model.FieldData.(FieldData.java:44)
at com.foxykeep.cpcodegenerator.model.TableData.(TableData.java:40)
at com.foxykeep.cpcodegenerator.model.TableData.getClassesData(TableData.java:66)
at com.foxykeep.cpcodegenerator.Main.main(Main.java:100)

I changed the code on line 44 to

if (dbIsAutoincrement && !type.equals("integer") && !type.equals("long")) {
throw new IllegalArgumentException("Field "" + name + "" | is_autoincrement can "
+ "only be used on an integer type field");
}

My question is...is autoincrement valid only on int types? Is long OK?

@frapontillo
Copy link
Contributor

AUTOINCREMENT is only valid on integers: http://www.sqlite.org/autoinc.html

@jbarwick
Copy link
Author

jbarwick commented Dec 4, 2013

that was fast....thanks.

@jbarwick jbarwick closed this as completed Dec 4, 2013
@writtmeyer
Copy link

You should know that SQLite only knows about the datatype "integer" and doesn't have the datatype "long". AFAIK SQLite changes any CREATE TABLE statement containing long types to integers anyway:

http://www.sqlite.org/datatype3.html

SQLite is very flexible and adapts to the actual data (the definition in CREATE TABLE is not that importantas in other relational databases). So inserting a long value into a integer column works fine.

@foxykeep
Copy link
Owner

foxykeep commented Dec 4, 2013

Wolfram is right. My code is actually changing Java longs into SQLite
integers IIRC.

Nicolas KLEIN aka Foxykeep

On Wed, Dec 4, 2013 at 2:37 AM, Wolfram Rittmeyer
notifications@github.comwrote:

You should know that SQLite only knows about the datatype "integer" and
doesn't have the datatype "long". AFAIK SQLite changes any CREATE TABLE
statement containing long types to integers anyway:

http://www.sqlite.org/datatype3.html

SQLite is very flexible and adapts to the actual data (the definition in
CREATE TABLE is not that importantas in other relational databases). So
inserting a long value into a integer column works fine.


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-29794559
.

@jbarwick
Copy link
Author

jbarwick commented Dec 5, 2013

I guess the next question I have is: is a SQLite integer the same size as a java long or a java int. if it the same size as a java long then my requested code change is valid (auto-increment on a java long)

I guess the question is: are we using the JSON def file just to create a SQLite provider or is this also a way to, one day, auto-generate a data model java class structure.

I was using the mdsd-content-provider-generator which reads an ecore model and attempts to generate both the provider and the model.

It was an interesting exercise, but it's just too incomplete to be very useful when trying to build a model with complex (or even simple) relationships. An the code is one year old untouched.

So, I am warming up to foxykeep's take on creating a provider (very different than mdsd!!) and creating the data object model manually. Probably better that way.

Thanks guys.

Sent from my iPhone

On 5 Dec, 2013, at 12:37 am, Foxykeep notifications@github.com wrote:

Wolfram is right. My code is actually changing Java longs into SQLite
integers IIRC.

Nicolas KLEIN aka Foxykeep

On Wed, Dec 4, 2013 at 2:37 AM, Wolfram Rittmeyer
notifications@github.comwrote:

You should know that SQLite only knows about the datatype "integer" and
doesn't have the datatype "long". AFAIK SQLite changes any CREATE TABLE
statement containing long types to integers anyway:

http://www.sqlite.org/datatype3.html

SQLite is very flexible and adapts to the actual data (the definition in
CREATE TABLE is not that importantas in other relational databases). So
inserting a long value into a integer column works fine.


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-29794559
.


Reply to this email directly or view it on GitHub.

@foxykeep
Copy link
Owner

foxykeep commented Dec 5, 2013

AFAIK there is no limit besides the os limit on the size of sqlite
integers. I've been saving java long into sqlite integers forever. So it
should work.

Nicolas Klein aka Foxykeep
On Dec 4, 2013 11:13 PM, "jbarwick" notifications@github.com wrote:

I guess the next question I have is: is a SQLite integer the same size as
a java long or a java int. if it the same size as a java long then my
requested code change is valid (auto-increment on a java long)

I guess the question is: are we using the JSON def file just to create a
SQLite provider or is this also a way to, one day, auto-generate a data
model java class structure.

I was using the mdsd-content-provider-generator which reads an ecore model
and attempts to generate both the provider and the model.

It was an interesting exercise, but it's just too incomplete to be very
useful when trying to build a model with complex (or even simple)
relationships. An the code is one year old untouched.

So, I am warming up to foxykeep's take on creating a provider (very
different than mdsd!!) and creating the data object model manually.
Probably better that way.

Thanks guys.

Sent from my iPhone

On 5 Dec, 2013, at 12:37 am, Foxykeep notifications@github.com wrote:

Wolfram is right. My code is actually changing Java longs into SQLite
integers IIRC.

Nicolas KLEIN aka Foxykeep

On Wed, Dec 4, 2013 at 2:37 AM, Wolfram Rittmeyer
notifications@github.comwrote:

You should know that SQLite only knows about the datatype "integer"
and
doesn't have the datatype "long". AFAIK SQLite changes any CREATE
TABLE
statement containing long types to integers anyway:

http://www.sqlite.org/datatype3.html

SQLite is very flexible and adapts to the actual data (the definition
in
CREATE TABLE is not that importantas in other relational databases).
So
inserting a long value into a integer column works fine.


Reply to this email directly or view it on GitHub<
https://github.com/foxykeep/ContentProviderCodeGenerator/issues/22#issuecomment-29794559>

.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-29876240
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants