Giter VIP home page Giter VIP logo

import-query-generator's People

Contributors

dineshsailor avatar kfirba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

import-query-generator's Issues

Conditional column update

Hey there @kfirba first let me thank you for your effort to bring such an useful tool.

May I suggest to add basic support for conditional updated columns?
I've started using your tool but soon I realised that I had to edit the generated query myself.
Here's the case:

My table had updated_at column so in my insertOrUpdate values I had to set it with the current time before the db request. The problem is the query treats it as an update value when it actually should be set only when another of the columns is updated.
On the other hand you can't excluded it because you need it to show when the update has occurred.

So I had to add the following line

on duplicate key update 
    updated_at=IF(name=VALUES(name), updated_at, VALUES(updated_at) )

right after the on duplicate key update clause before all other updating columns so that it checks the value before name is set in order to compare the values between the new value and the one of the table record. As you see the updated_at receives the new value only when name is different than the current value of the table.
Which brings the idea for conditional update columns where a conditional column is checked against change of value among other given columns like

[ 'updated_at' => ['name', 'color', ....] ] 

where it generates the following line in the query

updated_at=IF(
   name=VALUES(name) && color=VALUES(color) && ...., 
   updated_at, VALUES(updated_at) 
)

Unable to install package

[InvalidArgumentException]                                                                                                                           
  Could not find package kfirba/import-query-generator at any version for your minimum-stability (stable). Check the package spelling or your minimum  
  -stability   

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.