medly / medly/norm

Feature Request - Support Dynamic Where Clauses for Query

Open
#38 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

codegen design discussion required enhancement hacktoberfest
Dominant language
Kotlin
Stars
19
Forks
21
PR merge metrics
No merged PRs in 30d

Description

Hi Team,

We need a Feature in NORM where we don't have to write multiple queries for multiple cases/filters which we want rather NORM should be able to take decision on its own that if Given Param is NULL/Empty is some case it should not add its Column in WHERE clause.

For Example -

We want to have a Users API where we want to support filtering by name, address_line, city, state and zip_code.

Current Solution -

We have to write multiple queries for each case like

SELECT * FROM users WHERE name = 'XXXX';
SELECT * FROM users WHERE address_line = 'XXXX';
....
....
SELECT * FROM users WHERE zip_code = 'XXXX';

And then if we need combination we will need combinations also, then we would few more queries like

SELECT * FROM users WHERE zip_code = 'XXXX'; AND city = 'XXXX'; and so on.......

Expected Solution -

NORM should generate query on the fly according to Parameters given to it like below code somewhat -

if (!addressLine.isNullOrEmpty()) then
query = query + WHERE a.address_line = addressLine

if (!city.isNullOrEmpty()) then
query = query + WHERE a.city = city

if (!state.isNullOrEmpty()) then
query = query + WHERE a.state = state

if (!zip_code.isNullOrEmpty()) then
query = query + WHERE a.zip_code = zip_code

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

No files, tests, or entry points are named. Start by locating NORM's query-construction API and reviewing how its SQL queries currently accept filters; define the intended behavior for absent and combined parameters before implementation. Done means a documented query approach handles the listed optional filters without requiring a separate query for each combination.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, sql
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.