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

Core: New implicits in core.Predef breaks logic with Expression[Any] #4195

Closed
jigarkhwar opened this issue Jan 21, 2022 · 3 comments
Closed
Assignees
Milestone

Comments

@jigarkhwar
Copy link

jigarkhwar commented Jan 21, 2022

Hello!
When I migrated to gatling, I noticed a problem with the new implicits in import io.gatling.core.Predef._

implicit def integerToFiniteDurationExpression(i: Integer): Expression[FiniteDuration] = intToFiniteDuration(i.toInt).expressionSuccess
 implicit def intToFiniteDurationExpression(i: Int): Expression[FiniteDuration] = i.seconds.expressionSuccess
 implicit def jlongToFiniteDurationExpression(i: java.lang.Long): Expression[FiniteDuration] = i.toLong.seconds.expressionSuccess

Use Case:
our jdbc plugin https://github.com/Tinkoff/gatling-jdbc-plugin/blob/5edf8a2c6441d0af80b2f16e52e276591e195a4b/src/test/scala/ru/tinkoff/load/jdbc/test/cases/Actions.scala#L36

My script:
InsertInto("TEST_TABLE", Columns("ID", "NAME")).values("ID" -> 20, "NAME" -> "Test 12"),
def values(values: (String, Expression[Any])*)

An unexpected implicit conversion occurs
image

and I Get errors because it converts Int -> FiniteDuration
Data conversion error converting "'20 seconds' SQL statement: (TEST_TABLE: ""ID"" INTEGER NOT NULL)"

Also I noticed a problem with gatling-core dsl

.doIfEquals(_("myInt").as[Int], 1){
          exec()
        }

.doIfEquals(1, 1){
          exec()
        }

image
image
image

and other cases with http queryParam, http formParam, jms etc.
https://github.com/gatling/gatling/search?q=Expression%5BAny%5D

Could you revert that implicits? We need implicit def value2Expression

@slandelle
Copy link
Member

Hello,

Thanks for reporting.
Sadly, this is something we'll only be able to fix for Gatling 3.8 as the fix will break binary compatibility.

@jigarkhwar
Copy link
Author

Thanks!
how soon it will be possible?

@slandelle slandelle changed the title New implicits in core.Predef breaks logic with Expression[Any] Core: New implicits in core.Predef breaks logic with Expression[Any] Jan 21, 2022
@slandelle slandelle self-assigned this Jan 21, 2022
@slandelle slandelle added this to the 3.8.0 milestone Jan 21, 2022
@slandelle
Copy link
Member

Unless it becomes a blocking issue for customers, only when we'll have new features to publish. Probably 2-3 months then.

@slandelle slandelle reopened this Jan 24, 2022
slandelle added a commit that referenced this issue Jan 24, 2022
…#4195

Motivation:

In 3.7, we introduced `Int => Expression[FiniteDuration]`  implicit conversions.
In some cases, for example `queryParam("foo", 1)`, we want the existing `T => Expression[T]` implicit conversion to trigger, but the new implicit seems to have higher priority, probably because it's more precise.

Modification:

* drop the new implicit Expression[FiniteDuration] conversions
* add a new function to Expression implicit conversion
* make sure that value to Expression implicit conversion can't be applied on Strings (we want to EL conversion to trigger)
* the Scala compiler doesn't properly figure out implicit conversions when using overloading. I couldn't figure out the rules here?! Use more overloads to remove some of the needs of implicit conversions and convert manually instead.

Result:

`queryParam("foo", 1)`, properly generate an `Expression[Int]` and not an `Expression[FiniteDuration]`.
@slandelle slandelle modified the milestones: 3.7.6, 3.8.0 Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants