Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
最速のクエリビルダを妄想してみた
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
mackee
June 13, 2015
Programming
87
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
最速のクエリビルダを妄想してみた
mackee
June 13, 2015
More Decks by mackee
See All by mackee
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
820
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
1.3k
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
6
6.4k
今!ソフトウェアエンジニアがハードウェアに手を出すには
mackee
14
7.5k
ワンバイナリWebサービスのススメ
mackee
10
9.2k
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
850
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
1.2k
perl for shell, awk and sed programmers
mackee
3
2.9k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
1.1k
Other Decks in Programming
See All in Programming
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
3k
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
120
Intent as Code
shoppingjaws
6
1k
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
720
一人だけ、Kiroが静止する日
hideg
0
110
Webの地図
yosuke_furukawa
PRO
6
4.6k
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
480
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
160
What We Talk About When We Talk About XP
m_seki
2
640
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
180
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
250
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
320
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1.6k
Accessibility Awareness
sabderemane
1
210
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
400
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
550
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.9k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
240
Transcript
࠷ͷΫΤϦϏϧμΛ ໝͯ͠Έͨ @mackee_w a.k.a Ϛίϐʔ ΠΧID: mackee_w
YAPCԠื͍ͯ͠·͢ • http://yapcasia.org/2015/talk/show/ a668ef3e-080b-11e5-b2b4-79c97d574c3a • Ͳ͏ͯ͠PerlͰυϩʔϯΛඈ͍ͨ͠ਓͷͨ ΊͷϋʔυΣΞϋοΫ֓ • ·ͨͷ໊Λୁั͞Εͳ͍ͨΊʹυϩʔϯΛඈ ͨ͢Ίͷ97ͷ͜ͱ
GoͷΫΤϦϏϧμ • lann/squirrel import sq “github.com/lann/squirrel” query, args, err :=
sq.Select(“id”, “name”).From(“user”).Where(sq.Eq{“id”: id}).ToSql() row := db.QueryRow(query, args…)
sq.Where(sq.Eq{“id”: id}) ↑͍ͭ͜ϦϑϨΫγϣϯ
ͦsquirrelΫΤϦϏϧμ • ΫΤϦϏϧμͳͷͰεΩʔϚΛΒͳ͍ • εΩʔϚΛΒͳ͍ͷͰΧϥϜͷܕΛΒͳ ͍ • ͱ͍͏͔interface{}ͳͷͰͳΜͰಥͬࠐΊΔ • errorͱ͔ಥͬࠐΊΔɺͦͯ͠panicΔ
ϦϑϨΫγϣϯͷޭࡑ • ϦϑϨΫγϣϯʹΑΓͱΓ͋͑ͣinterface{}Ͱ ड͚ͯͦͷޙͷ͜ͱޙͰߟ͑ΔΈ͍ͨͳ͜ ͱ͕ग़དྷΔ • ͦͷΘΓʹಈ͍͍ͯΔͱ͖ʹpanicΔͷͰਓ ͕͕ؒΜͬͯpanicΒͳ͍Α͏ʹಥͬࠐΉ ͷΛࢹ͠ͳ͚ΕͳΒͳ͍
ܕͱԿͩͬͨͷ͔ (GoܕϏονݴޠͱ͍͏ ͜͜Ͱແࢹ͓ͯ͘͠)
sqlla - a pre- generated structure query buillder - ͔࣍ΒໝͰ͢
go generate • Go1.4͔Βgo generateͱ͍͏Έ͕Ճ ͞Εͨ • //go:generate hogehoge •
͜ΕΛهड़ͨ͠ιʔε͕ଘࡏ͢Δͱ͜ΖͰgo generateͬͯίϚϯυΛଧͭͱhogehogeͬͯ ͍͏ͷ͕γΣϧͰ࣮ߦ͞ΕΔ
༻ྫ • https://godoc.org/golang.org/x/tools/cmd/ stringer จࣈྻԽग़དྷΔఆΛ࡞ΔͨΊͷ generater • ఆͷ্ʹίϝϯτͰΞϊςʔγϣϯΛ࡞Δ ͱ fmt.Stringerͱ͍͏interfaceΛ࣮ͨ͠type
Λఆٛͯ͠จࣈྻԽग़དྷͯศར
argen • ੩తղੳϕʔεͷORM • //+ARͬͯstructʹॻ͘ͱ͍Ζ͍Ζ࣮ͯ͘͠ ΕΔ(?)
genddl • ࡞ͷDDLੜث • //+table: <ςʔϒϧ໊>ͬͯstructʹॻ͍ͯΧ ϥϜ໊ͱ͔ΛλάͰॻ͘ͱDDLΛੜͯ͘͠ ΕΔ
ಓ۩ • go/parser + go/ast • text/template
ࠓճໝͨ͠ͷ • ੩తղੳϕʔεͷΫΤϦϏϧμ import ( “github.com/mackee/sugoiapp/schema/user” ) user.UserId{1}.Name{“name”}.ToSql()
த //+table: user type User struct { Id uint64 `db:”id”`
Name string `db:”name”` }
͔͜͜Βauto generated type Name struct { Name string Expr sqlla.Expr
} func (c Name) ToSql() { return “name “ + c.Expr.ToSql() + “?” }
͋ͱϝιουνΣΠϯͱ͔ ͕ΜͬͯࣗಈੜϫΠϫ Π ྗٕ͡Ό
ͱ͍͏ͷΛ1࣌ؒલʹࢥ͍ͭ ͍ͨͷͰɺͦͷ͏࣮ͪ͠ͱ ͜(͜Ε͕Φν)