File tree 4 files changed +31
-1
lines changed
4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,18 @@ docker-compose -f docker-compose-test-mysql.yml up --build --remove-orphans
53
53
# in separate console window...
54
54
docker-compose -f docker-compose-test-mysql.yml run --rm tests bash
55
55
56
+ # inside the tests container
57
+ bundle exec rake
58
+ ` ` `
59
+
60
+ # # Running the tests with postgres
61
+
62
+ ` ` `
63
+ docker-compose -f docker-compose-test-postgres.yml up --build --remove-orphans
64
+
65
+ # in separate console window...
66
+ docker-compose -f docker-compose-test-postgres.yml run --rm tests bash
67
+
56
68
# inside the tests container
57
69
bundle exec rake
58
70
` ` `
Original file line number Diff line number Diff line change @@ -36,5 +36,10 @@ RUN gem install bundler -v '~>2.0.0' \
36
36
RUN echo '#!/bin/sh' >> /home/start.sh
37
37
RUN echo 'bundle exec rackup -o 0.0.0.0 -p 9292' >> /home/start.sh
38
38
RUN chmod +x /home/start.sh
39
+
40
+ RUN echo '#!/bin/sh' >> /home/init-db.sh
41
+ RUN echo 'bundle exec rake db:prepare:test' >> /home/init-db.sh
42
+ RUN chmod +x /home/init-db.sh
43
+
39
44
ENTRYPOINT bash
40
45
CMD []
Original file line number Diff line number Diff line change 18
18
password : postgres
19
19
host : localhost
20
20
port : " 5433"
21
+ docker_compose_postgres :
22
+ adapter : postgres
23
+ database : postgres
24
+ username : postgres
25
+ password : postgres
26
+ host : postgres
27
+ port : " 5432"
21
28
mysql :
22
29
<< : *default
23
30
adapter : mysql2
Original file line number Diff line number Diff line change @@ -25,13 +25,19 @@ module ClassMethods
25
25
module InstanceMethods
26
26
def insert_ignore ( opts = { } )
27
27
save ( opts )
28
+ load_values_from_previously_inserted_object unless id
29
+ self
28
30
rescue Sequel ::NoExistingObject
29
31
# MySQL. Ruining it for everyone.
32
+ load_values_from_previously_inserted_object
33
+ end
34
+
35
+ def load_values_from_previously_inserted_object
30
36
query = self . class . insert_ignore_identifying_columns . each_with_object ( { } ) do | column_name , q |
31
37
q [ column_name ] = values [ column_name ]
32
38
end
33
39
self . id = model . where ( query ) . single_record . id
34
- self . refresh
40
+ refresh
35
41
end
36
42
37
43
# Does the job for Sqlite and Postgres
You can’t perform that action at this time.
0 commit comments