Skip to content

add empty like check#4

Open
ggggxiaolong wants to merge 1 commit intoperdumonocle:masterfrom
ggggxiaolong:master
Open

add empty like check#4
ggggxiaolong wants to merge 1 commit intoperdumonocle:masterfrom
ggggxiaolong:master

Conversation

@ggggxiaolong
Copy link

@ggggxiaolong ggggxiaolong commented Sep 18, 2020

ignore like mask is "" or feild is ""

src/lib.rs Outdated
T: ToString,
{
let mut cond = field.to_string();
if cond.is_empty() || mask.to_string().is_empty() || mask.to_string().is_empty() { return self; }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate mask.is_empty

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

@pleshevskiy
Copy link

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

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

@perdumonocle
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants