Comments (9)
Indeed, this is one of the parts of Brillo that would probably fit better in Polo. It doesn't seem like the API would be affected at all either, since you already have a notion of DB specific adapters in Polo.
Potentially we'd just need something like
https://github.com/IFTTT/polo/blob/master/lib/polo/sql_translator.rb#L23
def to_sql
case @configuration.on_duplicate_strategy
when :ignore
@adapter.ignore_transform(inserts, records)
when :override
@adapter.on_duplicate_key_update(inserts, records)
else inserts
-- end
++ end + @adapter.table_footer(record.class.arel_table)
end
from polo.
hey, @volkanunsal. Long time no PR 😂. We missed you!
This is an interesting idea.
Though I must say this is pretty PostgreSQL specific, so I'm not sure how it fits in the scope of Polo.
At the same time, I think this is something we could try to squeeze in the postgres adapter.
What do you think?
Wanna take a stab at it?
from polo.
@nettofarah Ha, ok, I'll give it a try.
from polo.
This is a feature I would also find very useful
from polo.
Yeah, I was thinking about this today.
I think we could write a class for data ingestion.
We could add an import
method to Polo that you could run in development/test.
That method could then delegate to some adapter specific classes.
What do you guys think?
from polo.
Depends on if you want to bake this into the default Polo.explore
for postgres or not. If we always want the 'ALTER SEQUENCE' statement in the end, then you can just modify the existing #ignore_transform so it tacks on the 'ALTER SEQUENCE' statement at the end.
I'm already doing something similar:
File.open('filename') do |f|
f << Polo.explore(klass, ids).join(";\n")
f << ";\nALTER SEQUENCE #{klass.table_name}_id_seq RESTART WITH #{ids.max+1};\n"
end
from polo.
You can see how we handle this in Brillo (a Polo wrapper with some extra conventions) here
from polo.
@bessey maybe we can join forces and try to bring this feature over to Polo?
from polo.
niice! I like that.
We could even be a little extra defensive and do something like:
if @adapter.respond_to?(:table_footer)
...
end
from polo.
Related Issues (20)
- nil exception in conjunction with globlaize 3 HOT 2
- Issue with PostgreSQL adapter: ActiveRecord::StatementInvalid: PG::ProtocolViolation: ERROR HOT 7
- Keep a CHANGELOG HOT 1
- Create a CSV translator HOT 2
- How are you using Polo? HOT 7
- SQLite Support
- Usage examples
- Multi Database tests HOT 3
- obfuscate does not work with lambda HOT 12
- Suggestion: Make the ID param optional HOT 5
- Specify table name in obfuscate calls HOT 5
- NoMethodError: protected method `column_for_attribute' called for HOT 4
- Postgres support HOT 16
- has_and_belongs_to_many relationships will not store join table HOT 3
- Suggestion: Expose instance to obfuscation strategies HOT 2
- Rails 5.2 support HOT 2
- Rails 6.0 support HOT 3
- Project Status HOT 3
- Stream queries when traversing database to reduce memory footprint
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polo.