perdumonocle / sql-builder

Simple SQL code generator.
MIT License
123 stars 13 forks source link

add empty like check #4

Open ggggxiaolong opened 4 years ago

ggggxiaolong commented 4 years ago

ignore like mask is "" or feild is ""

pleshevskiy commented 4 years ago

I think we shouldn't merge this.

1) what if I want to search empty line? select name from products where description = ''; 2) why and when do you add empty column name? It seems like a bug. If you want to add dynamic query without mutable variable I think to add modify method will better than it.

ggggxiaolong commented 4 years ago

I think we shouldn't merge this.

  1. what if I want to search empty line? select name from products where description = '';
  2. why and when do you add empty column name? It seems like a bug. If you want to add dynamic query without mutable variable I think to add modify method will better than it.
  1. search empty line use and_where_eq not *_like
  2. sql like "%" or like "%%" is needless
perdumonocle commented 4 years ago

For example you have a filter on a form. And according of its value you show records from database and pinned records: .or_where("pin") .or_where_like_any(filter)

With empty filter you will see all records, and its a normal. In your variant you can see only pinned recods

perdumonocle commented 4 years ago

I have plans to make an universal WHERE query constructor, but I haven't yet decided how to make it convenient and visual

perdumonocle commented 3 years ago

go-sqlbuilder for golang looks awful:

sb := sqlbuilder.NewSelectBuilder()
sb.Select("id", "name", sb.As("COUNT(*)", "c"))
sb.From("user")
sb.Where(sb.In("status", 1, 2, 5))