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.4k
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
2
510
Minify Ruby Code
koic
2
2k
Permanent Agility
koic
35
7.1k
RuboCop: LSP and Prism
koic
3
4k
Organizational Pattern Hatching
koic
0
1.4k
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.3k
The Resurrection of the Fast Parallel Test Runner
koic
1
6.1k
Other Decks in Programming
See All in Programming
"noncopyable types" の使いどころについて考えてみた
andpad
0
150
Iteratorでページネーションを実現する
sonatard
3
710
Kubernetes上でOracle_Databaseの運用を楽にするOraOperatorの紹介
nnaka2992
0
150
Интеграционное тестирование: как приручить хаос
lamodatech
0
560
Pydantic x Database API:turu-pyの開発
yassun7010
1
560
C#および.NETに対する誤解をひも解く
ymd65536
0
250
Compose Multiplatform과 Ktor로 플랫폼의 경계를 넘어보자
kwakeuijin
0
260
Beyond Laravel Octane - Hyperf for Laravel Artisans
albertcht
1
130
CSC509 Lecture 03
javiergs
PRO
0
140
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
6
680
Removing Corepack
yosuke_furukawa
PRO
9
1.2k
Pythonによるイベントソーシングへの挑戦と現状に対する考察 / Challenging Event Sourcing with Python and Reflections on the Current State
nrslib
3
1.2k
Featured
See All Featured
How GitHub (no longer) Works
holman
311
140k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
7
580
Code Review Best Practice
trishagee
62
16k
KATA
mclloyd
27
13k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Music & Morning Musume
bryan
46
6.1k
Building a Scalable Design System with Sketch
lauravandoore
459
32k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Into the Great Unknown - MozCon
thekraken
30
1.4k
From Idea to $5000 a Month in 5 Months
shpigford
380
46k
4 Signs Your Business is Dying
shpigford
180
21k
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@TQFDJpDBUJPOSC-- SFRVJSF ࠶ܝ
None
None
Oracle enhanced adapter
Ҏ߱ͷ։ൃऀ
w SBJMTSBJMTʹଘࡏ͍ͯͨ͠ 0SBDMF"EBQU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DMFҎ֎ͷ+%#$αϙʔτ
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