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

Issue#4 Adding .singleOption #34

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

samikrc
Copy link

@samikrc samikrc commented Sep 15, 2024

No description provided.

@lihaoyi
Copy link
Member

lihaoyi commented Sep 15, 2024

Can you run the autoformatter? ./mill -i mill.scalalib.scalafmt.ScalafmtModule/reormatAll __.sources

@@ -219,7 +219,26 @@ object DbApi {
}
}
}


def runOption[Q, R](query: Q, fetchSize: Int = -1, queryTimeoutSeconds: Int = -1)(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this on DbApi. .single is implemented on Select and doesn't need any dedicated methods on DbApi, so I would expect singleOption would be similar

@@ -86,4 +92,17 @@ object Query {
protected override def queryConstruct(args: Queryable.ResultSetIterator): R =
query.queryConstruct(args).asInstanceOf[R]
}

/**
* A [[Query]] that wraps another [[Query]] but sets [[queryIsSingleRow]] to `true`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should state: sets [[queryIsSingleRowOption]] to true

* @param q
* @return
*/
def isSingleRowOption(q: Q): Boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if instead of adding another method isSingleRowOption, we should change the approach towards a method named cardinality (or something like that), that returns an enum value among: singleOptional, single or many.

I think the danger with the current approach is that we end up with two somewhat mutually exclusive cases: isSingleRow and isSingleRowOption ... what if they are both set to return true?

@samikrc
Copy link
Author

samikrc commented Sep 16, 2024

Thanks for all the comments - will work on these and put in some notes/discussions.

@timzaak
Copy link

timzaak commented Jan 31, 2025

If there's any update?

@samikrc
Copy link
Author

samikrc commented Jan 31, 2025

Sorry - I got stuck the last time running mill command as suggested by Li, and then never got to report back.
@lihaoyi : When running the format command, I am seeing this. Any pointer?

samik@SAMIK-LAP:~/git/out/myclones/scalasql$ mill -i mill.scalalib.scalafmt.ScalafmtModule/reormatAll __.sources
[61/61] ======================= mill.scalalib.scalafmt.ScalafmtModule/reormatAll __.sources ===========================
1 tasks failed
methodCodeHashSignatures os.ResourceNotFoundException: java.net.URLClassLoader@677b238a/mill/main/RootModule$Foreign.class
    os.ResourcePath.getInputStream(ResourcePath.scala:21)
    os.read$inputStream$.apply(ReadWriteOps.scala:245)
    mill.codesig.ExternalSummary$.load0$1(ExternalSummary.scala:55)
    mill.codesig.ExternalSummary$.$anonfun$apply$6(ExternalSummary.scala:48)
    scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
    scala.collection.mutable.HashMap.getOrElse(HashMap.scala:451)
    mill.codesig.ExternalSummary$.load$1(ExternalSummary.scala:48)
    mill.codesig.ExternalSummary$.$anonfun$apply$9(ExternalSummary.scala:69)
    mill.codesig.ExternalSummary$.$anonfun$apply$9$adapted(ExternalSummary.scala:69)
    scala.collection.immutable.BitmapIndexedSetNode.foreach(HashSet.scala:951)
    scala.collection.immutable.HashSet.foreach(HashSet.scala:958)
    mill.codesig.ExternalSummary$.apply(ExternalSummary.scala:69)
    mill.codesig.CodeSig$.compute(CodeSig.scala:17)
    mill.runner.MillBuildRootModule.$anonfun$methodCodeHashSignatures$2(MillBuildRootModule.scala:173)
    mill.define.Task$TraverseCtx.evaluate(Task.scala:215)

Here is some more info:

samik@SAMIK-LAP:~/git/out/myclones/scalasql$ mill --version
Mill Build Tool version 0.12.0
Java version: 21.0.5, vendor: Ubuntu, runtime: /usr/lib/jvm/java-21-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "Linux", version: 5.15.167.4-microsoft-standard-WSL2, arch: amd64

Was also planning to implement the idea from @aboisvert . Would proceed once the above issue is resolved.

@lihaoyi
Copy link
Member

lihaoyi commented Jan 31, 2025

@samikrc could you try rm -rf out/ and trying again? Can also try bumping to Mill 0.12.5, which I think had a workaround for that misbehavior (though we havent managed to pinpoint it)

@samikrc
Copy link
Author

samikrc commented Jan 31, 2025

@samikrc could you try rm -rf out/ and trying again? Can also try bumping to Mill 0.12.5, which I think had a workaround for that misbehavior (though we havent managed to pinpoint it)

Yep - bumped to 0.12.5 and that worked. Will get back with some more updates to the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants