Scala3対応について(WIP) #95
y-yoshinoya
started this conversation in
Ideas
Replies: 3 comments 3 replies
-
適当に実装してみたがscalapはあまり関係なかったので、 object Main extends App {
import dsl._
User.where(_.name.like("%taro%")).where(_.age === 1)
}
case class User(name: String, age: Integer) extends ActiveRecord
object User extends ActiveRecordCompanion[User]
trait ActiveRecord
trait ActiveRecordCompanion[T] {
var parameters: Seq[T => ActiveRecordRelation] = Nil
def where(f: T => ActiveRecordRelation): this.type = {
parameters = parameters :+ f
this
}
}
trait ActiveRecordRelation
object dsl {
extension (s: String)
def like(p: String) = new ActiveRecordRelation {}
extension[T] (t: T)
def ===(p: T) = new ActiveRecordRelation {}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
・現状のScala ActiveRecordでは |
Beta Was this translation helpful? Give feedback.
2 replies
-
構文木を解析するのはなかなか骨が折れる作業のためバックエンド(SQL生成)に上記を使用できないか検討中 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
※英語をパッと書けないので日本語でご容赦下さい
現状、 SquerylライブラリにDB接続部分の大体の部分のバックエンドを依存しているため
Scala3による移行が困難なライブラリとなってしまっています。
理由としては、Squerylライブラリがscalapに依存しているためとなります。
Scala ActiveRecordをScala3に対応させるため、Squerylを使用しない形で
1からバックエンドを作ることを考えています。
(その方がRuby ActiveRecordの色々な機能を取り込みやすいのもあります)
scalap無しで以下のようなインターフェースが実現できるか調査が必要です。
上記については構想段階ですが、上記が実現可能ならほぼなんとかなると思っています。
ただ、現状Scala3の知識はほぼ0なのでこれからといったところです。。。
どなたかアイデアがありましたらご記載いただけますと助かります。
Beta Was this translation helpful? Give feedback.
All reactions