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
最速のクエリビルダを妄想してみた
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mackee
June 13, 2015
Programming
0
82
最速のクエリビルダを妄想してみた
mackee
June 13, 2015
Tweet
Share
More Decks by mackee
See All by mackee
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
620
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
6
5.1k
今!ソフトウェアエンジニアがハードウェアに手を出すには
mackee
14
6.6k
ワンバイナリWebサービスのススメ
mackee
10
8.5k
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
450
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
1.1k
perl for shell, awk and sed programmers
mackee
3
2.7k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
1.1k
database/sqlでNullを扱う歴史とsql.Null[T]の登場 / sql.Null[T] history
mackee
0
960
Other Decks in Programming
See All in Programming
存在論的プログラミング: 時間と存在を記述する
koriym
3
300
CS教育のDX AIによる育成の効率化
niftycorp
PRO
0
150
AI駆動開発の本音 〜Claude Code並列開発で見えたエンジニアの新しい役割〜
hisuzuya
4
530
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
3k
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
1.1k
20260315 AWSなんもわからん🥲
chiilog
2
170
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
2
240
CSC307 Lecture 15
javiergs
PRO
0
260
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
230
Migration to Signals, Signal Forms, Resource API, and NgRx Signal Store @Angular Days 03/2026 Munich
manfredsteyer
PRO
0
120
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
170
Fundamentals of Software Engineering In the Age of AI
therealdanvega
2
290
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
How to Ace a Technical Interview
jacobian
281
24k
Skip the Path - Find Your Career Trail
mkilby
1
87
Typedesign – Prime Four
hannesfritz
42
3k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
340
Writing Fast Ruby
sferik
630
63k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
410
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
490
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
380
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࣌ؒલʹࢥ͍ͭ ͍ͨͷͰɺͦͷ͏࣮ͪ͠ͱ ͜(͜Ε͕Φν)