Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 17 21:36
    willhausman opened #1891
  • Sep 17 21:36
    willhausman opened #1891
  • Sep 17 20:34
    jeremydmiller synchronize #1885
  • Sep 17 20:34
    jeremydmiller synchronize #1885
  • Sep 17 20:34

    jeremydmiller on linq-improvements

    Using ctid instead of id for qu… Preliminary work before refacto… WIP: optimizing collection quer… (compare)

  • Sep 17 20:34

    jeremydmiller on linq-improvements

    Using ctid instead of id for qu… Preliminary work before refacto… WIP: optimizing collection quer… (compare)

  • Sep 17 17:55
    willhausman closed #1883
  • Sep 17 17:55
    willhausman closed #1883
  • Sep 17 12:14
    devhb opened #55
  • Sep 17 00:50

    jeremydmiller on master

    Fix for GH-1888 to ensure the p… (compare)

  • Sep 17 00:50

    jeremydmiller on master

    Fix for GH-1888 to ensure the p… (compare)

  • Sep 17 00:50
    jeremydmiller closed #1890
  • Sep 17 00:50
    jeremydmiller closed #1890
  • Sep 17 00:50
    jeremydmiller closed #1888
  • Sep 17 00:50
    jeremydmiller closed #1888
  • Sep 16 15:35
    mysticmind synchronize #1882
  • Sep 16 15:35
    mysticmind synchronize #1882
  • Sep 16 15:35

    mysticmind on docs

    Remove sample name from all #en… Update readme relating to v4 do… Update readme [skip ci] and 12 more (compare)

  • Sep 16 15:35

    mysticmind on docs

    Remove sample name from all #en… Update readme relating to v4 do… Update readme [skip ci] and 12 more (compare)

  • Sep 16 15:25
    mysticmind opened #1890
Will Hausman
@willhausman
Found it. I do have the serializer configured, but the configuration for Casing was not where I expected.
So, I have serializer.Customize(c => c.ContractResolver = contractResolver) which allowed the inner newtsonsoft to use my settings, but I needed to also specify Casing on the Marten serializer itself for the sql generation to match it.
Jeremy D. Miller
@jeremydmiller
Will Hausman
@willhausman
On a subsequent read I spotted it. I had missed it the first time around, hence my confusion.
Jeremy D. Miller
@jeremydmiller
I think we need to make the Customize smart enough some day to detect the casing changes because that’s so brittle.
Jeremy D. Miller
@jeremydmiller
@oskardudycz @mysticmind Hey guys, I’ve got a window where I could throw all day tomorrow at Marten. There’s a few quickly actionable bugs, and one or two that would have to be tossed into 4.1 anyway. How would you feel about me sprinting through the bugs in the morning and whatever doc updates I can do in the afternoon / this weekend, let y’all review the docs, and then we actually try to cut v4 next week? Just damn the torpedos, launch the thing, and immediately start on 4.0.1 if bugs come in?
I’ll try to make a blogging push to go with it.
Selfishly, I’d love to see it live by the EventSourcing conf that Oskar & I are speaking at the 2nd week of October
@oskardudycz How do you feel about the event store docs? I’m personally good w/ “perfect is the enemy of the good” and we’ll continue to grow the docs to get it out
Jeff Doolittle
@jeffdoolittle
@jeremydmiller let me know how I can help. it will be nice to have the docs updated to match v4 :-D
Jeremy D. Miller
@jeremydmiller
Reviewing the new docs and providing feedback would be hugely helpful. If you want, you can run the new docs from the docs branch
./build.sh docs on OSX, build docs on windows to run the new docs. It’s a WIP, so there are still dead links and obvious gaps.
Oskar Dudycz
@oskardudycz
@jeremydmiller I’m good with releasing v4
I’ll try to work on ES docs asap; I had some nasty flu, but it seems to be better now. Indeed it’d be good to release it before the conference 👍
ridaamine94
@ridaamine94
Hello Guys, i know this question is maybe asked a lot of times but i did some research on the net and in marten documentation and i couldn't find a solution, but i'm wondering in version 3.13 is there a way to query using IsOneOf on a POCO,
for exemple my DTO has a property of type User with two fields inside and i want to query with something like this
_expression.And(campaign => dtoEntity.User.IsOneOf(users));
i tried overriding the Equals method, but i always get an exception thrown saying Can't infer NpgsqlDbType for type
Oskar Dudycz
@oskardudycz
I think that you may need to use the primitive types with IsOneOf
So you'd need to use e.g.dtoEntity.User.Id.IsOneOf(userIds)
ridaamine94
@ridaamine94
Though the check should be on both properties
public class User { public int UserId { get; set; } public UserType UserType { get; set; } }
Oskar Dudycz
@oskardudycz
Then you'd need to try to use Any or create a computed field
ridaamine94
@ridaamine94
Even Any does not work i get thrown with this exception
System.NotSupportedException The Expression is [RecordDto].User of type PropertyExpression
The code i tried is this _expression.And(entityDto=> users.Any(x => x == entityDto.User))
Oskar Dudycz
@oskardudycz
You'd still have to compare the primitve types
ridaamine94
@ridaamine94
And if go for the computed field approach should the field be also saved on the database ?
Oskar Dudycz
@oskardudycz
yes, then it'll be saved
It's needed, because Queryable provider is not using equals
it's translating the where syntax into the database query
so if it doesn't exist then it won't be find
ridaamine94
@ridaamine94
Ah Yes i see now, it's a bit messy having to go around like this, but i see the difficulty. However is support for CustomObjects is planned in the next releases of Marten ?
Jeremy D. Miller
@jeremydmiller
@ridaamine94 @oskardudycz Custom value types are technically supported through the IField & IFieldSource abstractions in v4, but that would get you to being able to query really just on equals comparisons. You could write your own overload method for IsOneOf().
Easiest thing to do might be to make extension methods on IMartenQueryable<T> for your custom object like:
that apply a WHERE clause on the primitive property types
Oskar Dudycz
@oskardudycz
...or you can always have a fallback with custom query using the Postgres json syntax
Jeremy D. Miller
@jeremydmiller
Gotta remember that Linq isn’t magic, and what’s really happening is that the Linq provider has to know how to interpret the code and use that to build up SQL to searh within JSON
Or that too. The syntax in the latest Postgresql is way, way better than the goofy original operators that we still use in the JSON support
Oskar Dudycz
@oskardudycz
Yup, depending on the postgres version you're using you could use JSON Path
Jeremy D. Miller
@jeremydmiller
Yeah, but they made something in v13 too that’s even easier I think
Oskar Dudycz
@oskardudycz
@ridaamine94 you could use MatchesSql with combination https://www.postgresqltutorial.com/postgresql-json/
Still, I agree that it'd be great to have support for such queryable, but as Jeremy said, it's much harder to implement than it looks like.
ridaamine94
@ridaamine94
@jeremydmiller @oskardudycz Thanks a lot for all the propositions you just gave, i'll try to cook up something with this.
I know that implementation is going to be a hard one to do. Best of lucks though in trying to set it up, i will be waiting for newer versions to see how you guys will magically code it.
Thanks a bunch guys.
Oskar Dudycz
@oskardudycz
:+1:
Feel free to ask for more hints if you stumble upon something :)
ridaamine94
@ridaamine94

Yes of course, just for information if someone falls upon something like this, this is the solution i have put in place,

private static string GenerateSqlForCustomType<TCustomType>(string customTypeName, TCustomType[] entities)
{

    return $"data -> '{customTypeName}' @> ANY (ARRAY [{entities.Select(e => $"'{JsonConvert.SerializeObject(e, new StringEnumConverter())}'").Join(",")}]::jsonb[])";

}

and for the usage i simply added this to MatchesSql in my query builder

_expression = _expression.And(dtoEntity =>       dtoEntity.MatchesSql(GenerateSqlForCustomType(nameof(dtoEntity.User), users)));
Jeremy D. Miller
@jeremydmiller
I think we could come up with something easier than that
ridaamine94
@ridaamine94
Yes i would be pleased to see the easier approach
Will Hausman
@willhausman
I am confused about some documentation contradiction. In https://marten-v4.netlify.app/guide/documents/querying/paging.html, at the bottom, it states that Stats() cannot be used with compiled queries. In https://marten-v4.netlify.app/guide/documents/querying/compiled-queries.html#querying-for-paginated-results, documentation describes using Stats(), however the sample code does not actually call Stats() on its query. If Stats() is supported on compiled queries now, what is the correct usage?
Will Hausman
@willhausman

Instead of the documented public QueryStatistics Stats { get; } = new(); automatic property, I have this,

private QueryStatistics stats;
public QueryStatistics Stats { get => stats; set => stats = value; }
QueryIs() =>  query => query.Stats(out stats).Skip(skipValue).Take(pageSize);

This compiles, but the documentation has me wondering if it works as intended.

Will Hausman
@willhausman
After sifting through Marten source, I believe I understand. The compiled query plan checks the class for an existing QueryStatistics property or field, and if it exists, appends the statistics to the db command builder. Seems like a good place to enhance documentation, since it happens automagically.
Jeremy D. Miller
@jeremydmiller
The v4 docs are a WIP. That’s what I’m supposed to be working on this afternoon, but not moving super fast today
Jeremy D. Miller
@jeremydmiller
@oskardudycz @mysticmind You'll never, ever guess this, but the Linq improvements are being a little harder than I'd hoped.
Still wanna shoot for next week if it seems remotely feasible
Oskar Dudycz
@oskardudycz
Do not put too much preasure on yourself. It'll be ready when it's ready. You already did a long run with it.