Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inList does not support multiple columns #643

Closed
babyfish-ct opened this issue Sep 18, 2019 · 5 comments
Closed

inList does not support multiple columns #643

babyfish-ct opened this issue Sep 18, 2019 · 5 comments

Comments

@babyfish-ct
Copy link

babyfish-ct commented Sep 18, 2019

Hi

Is it possible to support inList expression for multiple columns?

like this

.select {
tuple(Nodes.id, Nodes.version) inList idVersionTuples
}

@Tapac
Copy link
Contributor

Tapac commented Sep 18, 2019

And how it should works?
(id = 1 and version = 2) or (id = 3 and version = 4)
or
id in (1,3) and version in (2, 4)

@babyfish-ct
Copy link
Author

babyfish-ct commented Sep 18, 2019

It can be translated to standard SQL like this
where (name, version) in ((1, 2), (3, 4))
this is your first answer

but

  1. We often do not know the length of the list
  2. We also do not want to pull the huge list from remote db server to client side and generate the long sql dyanmically

So is it possible to support it like this

MyTable
    .slice(MyTable.name, MyTable.version, MyTable.description, MyTable.imageBlob)
    select {
        row(MyTable.name, MyTable.version) inList 
        wrapAsExpression<List<ResultRow2<Long, Int>>>(
            MyTable
                .slice(MyTable.name, MyTable.version.max())
                .selectAll()
                .groupBy(MyTable.name)
     )
}

@babyfish-ct
Copy link
Author

babyfish-ct commented Sep 18, 2019

My last example tells us this feature is important, this feature is supported by another java framework JOOQ, you can find these methods from its javadoc http://www.jooq.org/javadoc/latest/org.jooq/org/jooq/impl/DSL.html

1. Typesafe API for the row whose field count <= 22
    @Support public static <T1> Row1<T1> row​(T1 t1)
    @Support public static <T1,​T2> Row2<T1,​T2> row​(T1 t1, T2 t2)
    @Support public static <T1,​T2,​T3> Row3<T1,​T2,​T3> row​(T1 t1, T2 t2, T3 t3)
     .... ....
    @Support public static <T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16,​T17,​T18,​T19,​T20,​T21,​T22> Row22<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16,​T17,​T18,​T19,​T20,​T21,​T22> row​(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21, T22 t22)

2. Untypesafe API for the row whose field count > 22
    @Support public static RowN row​(Object... values)
    Create a row value expression of degree N > 22.

it's used like this

List<MyEntity> entities = context
     .select(
         MyTable.NAME, 
         MyTable.VERSION, 
         MyTable.DESCRIPTION, 
         MyTable.IMAGE_BLOB
    )
    .from(MyTable)
    .where(
        DSL.row(MyTable.NAME, MyTable.VERSION).in(
            context
                .select(MyTable.NAME, MyTable.VERSION.max())
                .from(MyTable)
                .groupBy(MyTable.NAME)
        )
    )
    .fetchInto(MyEntity.class)

@Tapac
Copy link
Contributor

Tapac commented Sep 20, 2019

What if only Pair and Triple will be supported at the start?

@babyfish-ct
Copy link
Author

babyfish-ct commented Sep 20, 2019

I think pair or triple is enough :)

Tapac added a commit that referenced this issue Apr 25, 2021
Tapac added a commit that referenced this issue Apr 25, 2021
Tapac added a commit that referenced this issue Apr 25, 2021
#643 / Exclude SQL Server from tests
@Tapac Tapac closed this as completed Apr 26, 2021
SchweinchenFuntik pushed a commit to SchweinchenFuntik/Exposed that referenced this issue Oct 23, 2021
SchweinchenFuntik pushed a commit to SchweinchenFuntik/Exposed that referenced this issue Oct 23, 2021
SchweinchenFuntik pushed a commit to SchweinchenFuntik/Exposed that referenced this issue Oct 23, 2021
JetBrains#643 / Exclude SQL Server from tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants