DataTables / DataTables/NET

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

Open
#18 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
19
Forks
11
PR merge metrics
No merged PRs in 30d

Description

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...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the provided SearchBuilderOptions sample as the reproduction, then compare the generated SQL on SQLite and SQL Server, focusing on the SELECT and GROUP BY handling for the Label value. Done means the sample generates valid SQL on SQL Server while preserving its SQLite behavior; confirm whether the MAX(sites.name) workaround is the intended behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.