Giter Site home page Giter Site logo

Comments (5)

Tapac avatar Tapac commented on May 2, 2024

The DEFAULT value clause in a data type specification indicates a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as the default for TIMESTAMP and DATETIME columns.
http://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html

So I guess Mysql doesn't truly support an expressions as columns default, especially comparing to PostgreSQL (https://www.postgresql.org/docs/9.3/static/ddl-default.html)

from exposed.

crazyproger avatar crazyproger commented on May 2, 2024

Ouch, thank you for clarification, @Tapac. I will create custom ColumnType for this purpose in my case.

from exposed.

Tapac avatar Tapac commented on May 2, 2024

You can use clientDefault{} to generate value on client side:

object : Table("") {
   val colWithDefault = integer("intCol").clientDefault { Random.nextInt() }
}

from exposed.

crazyproger avatar crazyproger commented on May 2, 2024

Thank you for suggestion, but I think some fields(created, modified in my case) better generate on database, for example with my table works not only kotlin code but also web-app(ruby/php/etc). And to not forget to generate it in all places better to generate it in one-DB.

from exposed.

Tapac avatar Tapac commented on May 2, 2024

Then triggers might suite your need, I guess.

from exposed.

Related Issues (20)

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.