DataTables / Editor-NET

.NET Framework and .NET Core server-side libraries for Editor
Other
15 stars 12 forks source link

SearchBuilderOptions()/SearchPaneOptions() generated invalid code on SqlServer #18

Open VictorioBerra opened 4 months ago

VictorioBerra commented 4 months ago

Modify the sample to the following code

.Field(new Field("sites.name")
    .SearchBuilderOptions(new SearchBuilderOptions()
        .Value("sites.id")
        .Label("sites.name")
        .LeftJoin("sites", "sites.id", "=", "users.site")
    )
)

This works on SQLite not SqlServer/MSSQL.

With SqlServer, you will get "Column '[sites].[name]' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."

Finally, "fixing" this is:

.Field(new Field("sites.name")
    .SearchBuilderOptions(new SearchBuilderOptions()
        .Value("sites.id")
        .Label("MAX(sites.name)")
        .LeftJoin("sites", "sites.id", "=", "users.site")
    )
)

Not sure if that is the appropriate fix though...

AllanJard commented 4 months ago

Hi - sorry I haven't been able to reply and look into your various issues and fixes yet. I'm working on other aspects of DataTables that I want to figure out before context switching to this. I will do so before the next release of Editor though.

VictorioBerra commented 4 months ago

@AllanJard no problem, I have created PRs for almost every issue I created now 🎉 hopefully this helps.