activerecord-import
activerecord-import copied to clipboard
Output SQL as string
It would be nice if there was a method like import_to_sql or something that would return the SQL string and not run the command against the database.
I'm not sure if this is the case, but I have a hunch that it would be less overhead for Ruby to output the SQL string to a file so that I can use mysql < the_outputted.sql to import the file.
Thoughts?
@lancecarlson, thanks for the suggestion. This sounds like a reasonable feature of activerecord-import. If you'd like to take a stab and submit a pull request I'd be happy to review and merge in; otherwise, you'll have to wait for me to get some free time.
:+1: I like this for debugging. Nice suggestion.
I like this idea a lot. I think I'd need to refactor before introducing this as there's not a great way to do this now.
I hit a strange bug after switching from mysql to postgresql. null
is sent as a primary key value. and I'd like to find out where the SQL is being generated. now I am getting this error.
ActiveRecord::StatementInvalid: PG::NotNullViolation: ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, ...
any help would be much appreciated.
this feature request could help, that's why I decided to post here, not knowing where else I can get help.
Love this idea -- has this been implemented?
@breathe nope it is still open. Like Zach mentioned above, I don't think the current implementation will make this an easy update, but if you're interested in working on it that would be awesome. I'm thinking an option like :preview_sql
would be my preference vs a new method.