Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The underground in ActiveRecord::ConnectionAdap...
Search
Koichi ITO
March 10, 2018
Programming
6
3.5k
The underground in ActiveRecord::ConnectionAdapters
沖縄Ruby会議02
http://ruby.okinawa/okrk02/
Koichi ITO
March 10, 2018
Tweet
Share
More Decks by Koichi ITO
See All by Koichi ITO
Beyond the RuboCop Defaults
koic
3
2.4k
Minify Ruby Code
koic
2
2.1k
Permanent Agility
koic
36
7.3k
RuboCop: LSP and Prism
koic
3
4k
Organizational Pattern Hatching
koic
0
1.5k
A Practitioner's Journey from Ruby 1.8 to Present
koic
1
2k
A Story Featuring Right Hand Archetype
koic
0
1.1k
Without Practice, No Emergence
koic
4
2.4k
The Resurrection of the Fast Parallel Test Runner
koic
1
6.1k
Other Decks in Programming
See All in Programming
C#/.NETのこれまでのふりかえり
tomokusaba
1
150
Prompt Engineering for Developers @ AWS Community Day Adria 2024
slobodan
0
120
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
10
2.3k
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
400
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
340
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
4
22k
qmuntal/stateless のススメ
sgash708
0
120
色々なIaCツールを実際に触って比較してみる
iriikeita
0
230
Synchronizationを支える技術
s_shimotori
1
150
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
8
930
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
410
2万ページのSSG運用における工夫と注意点 / Vue Fes Japan 2024
chinen
3
1.3k
Featured
See All Featured
A Philosophy of Restraint
colly
203
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.6k
KATA
mclloyd
29
13k
Gamification - CAS2011
davidbonilla
80
5k
Building Your Own Lightsaber
phodgson
102
6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
41
9.2k
Designing Experiences People Love
moore
138
23k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
Testing 201, or: Great Expectations
jmmastey
38
7k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
For a Future-Friendly Web
brad_frost
175
9.4k
Transcript
"DUJWF3FDPSE $POOFDUJPO"EBQUFST ͷԼͷੈ ք ླྀٿେֶֶ෦߸ؗ 4BU ԭೄ3VCZձٞ 5IFVOEFSHSPVOEJO"3$POOFDUJPO"EBQUFST %JWFUPUIFSBJMTSBJMTSFQPTJUPSZ
ג ӬγεςϜϚωδϝϯτ ҏ౻ߒҰ !LPJD
None
None
ࠓͷ
None
None
None
w %JWFUPSBJMTSBJMTSFQP w "3$POOFDUJPO"EBQUFST w 0SBDMFFOIBODFEBEBQUFS w 0SBDMFXJUI3BJMT "HFOEB ˞#BTFEPO3BJMTSD
Dive to rails/rails
None
None
None
None
None
None
AR::ConectionAdapters
w "3ͷϞσϧܦ༝Ͱͷݺͼग़͠ʹର͠ ͯɺ3%#.4͝ͱʹཧʹ͔ͳͬͨ42- ΛΈཱͯͯฦׂ͢ w 3%#.4ͷ༷Λલఏ͢Δɻྫ͑ 0SBDMFͩͱۭจࣈͱ/6--Λ۠ผ͠ ͳ͍ɺHἬࣝผࢠ͕จࣈҎԼ "3$POOFDUJPO"EBQUFST
SBJMTSBJMTͷςετͰΔ3%#.4ͷ ༷ʹΑΔৼΔ͍ͷҧ͍ DVSSFOU@BEBQUFS
rails/rails#29370
WTOJM
Ξμϓλͷࢦఆͱ 3BJMTΛىಈ࣌ͷ ৼΔ͍ʹ͍ͭͯ
w ͝ଘEBUBCBTFZNMʹࢦఆ͢Δ BEBQUFSͱԿͳͷ͔͍·Ұ $POOFDUJPO"EBQUFSͷબ development: adapter: mysql2 development: adapter: postgresql
development: adapter: sqlite3 development: adapter: oracle_enhanced
w EBUBCBTFZNMͰࢦఆͨ͠Ξμϓλ͕ SBJMTDSBJMTTͰཁٻ͞ΕΔἬͷྲྀΕ "33BJMUJFJOJUJBMJ[FS "3$POOFDUJPO)BOEMJOHFTUBCMJTI@DPOOFDUJ PO "3$POOFDUJPO"EBQUFST$POOFDUJPO4QFDJpD BUJPOTQFD FTUBCMJTI@DPOOFDUJPO
"33BJMUJFJOJUJBMJ[FS IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSESBJMUJFSC-
"3$POOFDUJPO)BOEMJOH FTUBCMJTI@DPOOFDUJPO IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@IBOEMJOHSC-
"3$POOFDUJPO"EBQUFST $POOFDUJPO4QFDJpDBUJPOTQFD IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTDPOOFDUJPO@TQFDJpDBUJPOSC-
w EBUBCBTFZNMͷࢦఆBEBQUFS ΛݩʹΞμϓλΛSFRVJSF͢Δ "3$POOFDUJPO"EBQUFST $POOFDUJPO4QFDJpDBUJPOTQFD path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter" begin require
path_to_adapter rescue LoadError => e (snip) end (snip) adapter_method = "#{spec[:adapter]}_connection" IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTDPOOFDUJPO@TQFDJpDBUJPOSC-- SFRVJSF
SFRVJSF͞ΕΔ$PSFBEBQUFST
w EBUBCBTFZNMͷࢦఆBEBQUFS ΛݩʹίωΫγϣϯϝιου໊Λܾఆ "3$POOFDUJPO"EBQUFST $POOFDUJPO4QFDJpDBUJPOTQFD path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter" begin require
path_to_adapter rescue LoadError => e (snip) end (snip) adapter_method = "#{spec[:adapter]}_connection" IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTDPOOFDUJPO@TQFDJpDBUJPOSC-- @DPOOFDUJPO
IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTNZTRM@BEBQUFSSC- @DPOOFDUJPO
IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTNZTRM@BEBQUFSSC- @DPOOFDUJPO %#$MJFOU
w 3VCZΦϒδΣΫτܦ༝Ͱ.Z42-Λૢ࡞͢Δ ΫϥΠΞϯτͱͳΔυϥΠό(FN require "mysql2" client = Mysql2::Client.new( :host =>
"localhost", :username => "root" ) results = client.query( "SELECT * FROM users WHERE group=‘githubbers'" ) results.each do |row| puts row["id"] # row[“id”].is_a? Integer if row["dne"] # non-existant hash entry is nil puts row["dne"] end end .ZTRMHFN IUUQTHJUIVCDPNCSJBONBSJPNZTRMVTBHF
"3ϞσϧͱυϥΠόͷதؒ $POOFDUJPO"EBQUFST "CTUSBDU"EBQUFS $POOFDUJPO "EBQUFST-BZFS "3.PEFM -BZFS %BUBCBTF $MJFOU-BZFS ˞ਤྫ.Z42-Ξμϓλ
(FNpMFʹࢦఆ ͍ͯ͠Δͷ͜Ε $POOFDUJPO"EBQUFST "CTUSBDU.ZTRM"EBQUFS $POOFDUJPO"EBQUFST .ZTRM"EBQUFS HFN NZTRM .Z42- %BUBCBTF -BZFS "3
"3ϞσϧͱυϥΠόͷதؒ $POOFDUJPO "EBQUFST-BZFS "3.PEFM -BZFS %BUBCBTF $MJFOU-BZFS ˞ਤྫ1PTUHSF42-Ξμϓλ (FNpMFʹࢦఆ ͍ͯ͠Δͷ͜Ε
$POOFDUJPO"EBQUFST 1PTUHSF42-"EBQUFS HFN QH 1PTUHSF42- %BUBCBTF -BZFS $POOFDUJPO"EBQUFST "CTUSBDU"EBQUFS "3
"3ϞσϧͱυϥΠόͷதؒ $POOFDUJPO "EBQUFST-BZFS "3.PEFM -BZFS %BUBCBTF $MJFOU-BZFS ˞ਤྫ42-JUFΞμϓλ (FNpMFʹࢦఆ ͍ͯ͠Δͷ͜Ε
$POOFDUJPO"EBQUFST 42-JUF"EBQUFS HFN TRMJUF 42-JUF %BUBCBTF -BZFS $POOFDUJPO"EBQUFST "CTUSBDU"EBQUFS "3
w EBUBCBTFZNMʹج͍ͮͨ $POOFDUJPO"EBQUFSTΛ͏ w $POOFDUJPO"EBQUFSͷઌͷଓ σʔλϕʔευϥΠόHFNͱͳΔ w NZTRM QH TRMJUFͳͲ
"3ͷσʔλϕʔεଓͷߏ
w SBJMTSBJMTϦϙδτϦͰϝϯςφ ϯε͞Ε͍ͯΔΞμϓλΛࢦ͢ w ݱࡏ.Z42- NZTRM 1PTUHSF42-42-JUFͷͭ w 3BJMTͷ$*ϚτϦοΫεʹೖͬͯΔ
$PSFBEBQUFST
w ֎෦(FNͱͯ͠ཁٻ͞ΕΔΞμϓλ w 0SBDMF w 42-4FSWFS w 'JSFCJSE w FUD
FUD SEQBSUZBEBQUFST
w 3BJMTຊମʹόϯυϧ͞Ε͍ͯΔίΞ ΞμϓλҎ֎͜͜ͰSFRVJSFͯ͠Δ "3$POOFDUJPO"EBQUFST $POOFDUJPO4QFDJpDBUJPOTQFD path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter" begin require
path_to_adapter rescue LoadError => e (snip) end (snip) adapter_method = "#{spec[:adapter]}_connection" IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTDPOOFDUJPO@TQFDJ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ఆ KBS PKECDKBS $POOFDUJPO"EBQUFST "CTUSBDU"EBQUFS "3
w KSVCZBDUJWFSFDPSEKECDBEBQUFS Ͱཧ͞Ε͍ͯΔ <ิ>0SBDMFҎ֎ͷ+%#$αϙʔτ
A development of Oracle enhanced adapter
w */%&9ʹؔ͢Δ5"#-&41"$&Λࢦఆ Ͱ͖ΔΑ͏ʹରԠͨ͠<> w SBJMTECTDIFNBMPBEͷϚϧνΠϯ αʔτʹରԠͨ͠<> w 3VCZ0$*Λ3VCZͷ #JH%FDJNBMରԠ<SVCZPDJ> ࢥ͍ग़ͷύονબ
w */%&9ʹؔ͢Δ5"#-&41"$&Λࢦఆ Ͱ͖ΔΑ͏ʹରԠͨ͠<> w SBJMTECTDIFNBMPBEͷϚϧνΠϯ αʔτʹରԠͨ͠<> w 3VCZ0$*Λ3VCZͷ #JH%FDJNBMରԠ<SVCZPDJ> ͡ΊͯͷΞμϓλύον
rsim/oracle-enhanced#1028
w 0SBDMFͰ5"#-&41"$&Ͱςʔϒϧ ΠϯσοΫεͷอଘྖҬࢦఆ͕Ͱ͖Δ w 0SBDMFFOBIBODFEBEBQUFSͰ EFGBVMU@UBCMFTQBDFTͰࢦఆՄೳ w QSJNBSZLFZʹରͯ͠͏·͘ޮ͔ͳ ͔ͬͨͷͰͨ͠ 5"#-&41"$&ͷࢦఆ
w ࣌ࣗ৴͕ͳ͘*TTVFͰ͓͍ खݩʹϞϯΩʔύον͋ͬͨ
w 54@*/%&9Ͱͳ͘54@%"5"ʹೖͬͯͨ ͷमਖ਼ύον 0QFOB13
"3.JHSBUJPOͷDSBFUF@UBCMFͷ SEQBSUZΞμϓλ࣮ͷมߋ தུ Ճ IUUQTHJUIVCDPNSTJNPSBDMFFOIBODFECMPCWSDMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTPSBDMF@FOIBODFETDIFNB@TUBUFNFOUTSC-
w "-5&3*/%&93*-%5"#-&41"$&Λ ࣮ߦ͢ΔϝιουΛఆ͍ٛͯ͠Δ ADSFBUF@UBCMFA͔ΒͷϑοΫ
w ϦϙδτϦΛԣஅͨ͠มߋ͕ඞཁͩͬͨ $*͕ͱ͓Βͳ͍
w 64&34Ͱͳ͘4:45&.ʹอଘ͞Εͯͨ w %&'"6-55"#-&41"$&ͷมߋ w 0SBDMF͚ͷSBJMTEFWCPYͷ13 ZBIPOEBSBJMTEFWCPY
w 3%#.4ͷΞμϓλ։ൃͳͷͰ 3%#.4ʹԠͨ͡։ൃڥΛඋ͢Δ ඞཁ͕͋Δ w ZBIPOEBSBJMTEFWCPY͕ 0SBDMF͚ͷ։ൃڥͱͳΔ w $*ͱ߹Θͤͯ͜ͷڥΛ͏ͷ͕ྑ͍ ։ൃڥͷݟΛಘΔ
Oracle with Rails 6.0
w 3BJMTҎલϓϥΠϚϦΩʔ*%ͷ ࠾൪ʹ͍ͭͯ4&26&/$&Ͱ͍ग़͞ Ε͍ͯΔ w 3BJMTҎ߱0SBDMFDͷ *EFOUJUZ$PMVNOΛ͏ํͰݕ౼ w OFYUWBMͱ͍͏1P$ͷϦϒʔτ 1P$*EFOUJUZ
w 3BJMTҎલͷσϑΥϧτ EFGBVMU@TFRVFODF@TUBSU@WBMVF w 3BJMTҎޙͷσϑΥϧτ EFGBVMU@TFRVFODF@TUBSU@WBMVF ʹͳΓଞͷΞμϓλͱಉ͡ڍಈʹ $IBOHFAEFGBVMU@TFRVFODF@TUBSU@WBMVFA GSPNUP
w SBJMTECTUSVDUVSFEVNQͷࡍ ʹσϑΥϧτͰ7*&8͕μϯϓ͞Ε ΔΑ͏ʹͳΔ &YUSBDUWJFXTUPEC TUSVDUVSFTRMCZEFGBVMU
w 0SBDMF%"5"#"4&-*/,ͱ͍͏ ଞͷ%#ͷσʔλΛҾ͘ػߏ͕͋Γ 3BJMTܥ0SBDMFΞμϓλἬαϙʔτ w 3BJMTҎޙ3BJMTͷෳ%#ର ԠʹͤΔ͜ͱʹͳΓػೳআ͢Δํ SBJMTSBJMTࢀর %SPQEBUBCBTFMJOLTVQQPSU
%SPQEBUBCBTFMJOLTVQQPSU
w "3#BTFDPOOFDUJPOUBCMFTͷ ΓʹؚΊͯΔϚςϏϡʔΛ֎͠ςʔ ϒϧͷΈฦ͢Α͏ʹ͢Δ͔Ͳ͏͔ʁ w 1PTUHSF42-Ξμϓλʹ͓͚Δಉϝ ιου͕ϚςϏϡʔΛฦ͔͢Ͳ͏͔ʹ ΑΔ (JU)VCίϝϯτௐ &YDMVEFANBUFSJBMJ[FE@WJFXTA
GSPNAUBCMFTA
w 0SBDMFD3ҎԼͰΧϥϜ໊ͳ ͲࣝผࢠʹόΠτҎԼͷ੍ݶ͕͋Δ w SBJMTSBJMTͷ"3ͷҰ෦ͷςετ͕ 0SBDMFͰམͪΔ͍ͪཁҼͰ͋Δ w 0SBDMFD3Ҏ্όΠτ ·Ͱͷ֦ு͞ΕΔ͚ͲͲ͏͢Δʁ -POHJEFOUJpFSTTVQQPSU
+3VCZ +%#$TVQQPSUT0SBDMFD PSIJHIFS1%# 1MVHHBCMFEBUBCBTF
Oracle enhanced 6.0 may require Oracle 12c or higher
w ਓྨͰݟ͍ͯΔਓ͕ݶΒΕ͍ͯΔͱ͍͏ $POOFDUJPO"EBQUFSTͷׂͱߏͱ ϦϙδτϦͰͷॴʹ͍ͭͯ͠·ͨ͠ w "SFMपล͍͠ͷͰׂѪ͍ͯ͠·͕͢ɺ ͜ͷ͋ͨΓ৮ΕΔͱ͔ͳΓڧ͍ͱࢥ͍·͢ w LBNJQP͞ΜͱZBIPOEB͞Μ͍͢͝ਓ ͓ΘΓʹ
None