robotoworks / mechanoid

Eclipse plugin providing a set of DSL's for the rapid development of Android apps
58 stars 26 forks source link

sqlite insert statements in .mechdb file supported? #195

Closed mrjbg closed 11 years ago

mrjbg commented 11 years ago

Well the title says it all :)

Does mechanoid support plain sql insert statements like for example:

insert into mytable values(1, 'text', 3.0);

If not could you please add this feature?

The idea is that I want to have a pre-populated database in my app.

Thanks!

fluxtah commented 11 years ago

That is out of the scope for schema migrations but this is something you can achieve by overriding the generated migration class as described in the docs. I will paste a link when I am at my machine later. 

Sent from Samsung Mobile

-------- Original message -------- From: mrjbg notifications@github.com Date:
To: robotoworks/mechanoid mechanoid@noreply.github.com Subject: [mechanoid] sqlite insert statements in .mechdb file supported? (#195)

Well the title says it all :)

Does mechanoid support plain sql insert statements like for example:

insert into mytable values(1, 'text', 3.0);

If not could you please add this feature?

The idea is that I want to have a pre-populated database in my app.

Thanks!

— Reply to this email directly or view it on GitHub.

mrjbg commented 11 years ago

Hi thanks for the reply. The problem with your solution is that it can get REALLY cumbersome if I have a pre-existing data with thousands of rows. If I can just paste the sql insert statements it would save me huge amounts of work.

Cheers!

fluxtah commented 11 years ago

Where would these thousands of rows come from? It might be best then to just add a plain text file with statements terminated by semicolon, parse it and exec each line as raw sql either before or after a migration wherever it makes sense. 

Mechanoid will give you great value for schema migrations but for data migrations you should use an approach that is more efficient.

Sent from Samsung Mobile

-------- Original message -------- From: mrjbg notifications@github.com Date:
To: robotoworks/mechanoid mechanoid@noreply.github.com Cc: Ian Warwick fluxtah@hotmail.com Subject: Re: [mechanoid] sqlite insert statements in .mechdb file supported? (#195)

Hi thanks for the reply. The problem with your suggestion is that it can get REALLY cumbersome if I have a pre-existing data with thousands of rows. If I can just paste the sql insert statements it would save me huge amounts of work.

Cheers!

— Reply to this email directly or view it on GitHub.

mrjbg commented 11 years ago

Whether I parse those sql statements from a text file or have them hard coded is actually irrelevant. The point is that I need to be able to raw-add (e.g. insert that data) into the sqlite database.

I saw where I could add those lines to the XYZDBOpenHelper, however this class is generated and adding code to classes that are generated is not a smart move. The next time mechanoid regenerates this class I will just loose my data, or if I have a backup I will have to add the raw sql insert statements again, which defeats the purpose of an automation tool.

fluxtah commented 11 years ago

Mechanoid has a generate once policy by default for user editable stubs (defaults to src folder), and a generate always policy for base code that you should not touch, abstracts, etc (defaults to src-gen).

In a nutshell editing any file in src by default your code is safe and Mechanoid will not regen on top of that.

Hope that makes sense.

Sent from Samsung Mobile

-------- Original message -------- From: mrjbg notifications@github.com Date:
To: robotoworks/mechanoid mechanoid@noreply.github.com Cc: Ian Warwick fluxtah@hotmail.com Subject: Re: [mechanoid] sqlite insert statements in .mechdb file supported? (#195)

Whether I parse those sql statements from a text file or have them hard coded is actually irrelevant. The point is that I need to be able to raw-add (e.g. insert that data) into the sqlite database.

I saw where I could add those lines to the XYZDBOpenHelper, however this class is generated and adding code to classes that are generated is not a smart move. The next time mechanoid regenerates this class I will just loose my data, or if I have a backup I will have to add the raw sql insert statements again, which defeats the purpose of an automation tool.

— Reply to this email directly or view it on GitHub.

fluxtah commented 11 years ago

Closing this issue since there are no plans to support DML statements in migrations.