Giter Club home page Giter Club logo

Comments (2)

MarcKaufmann avatar MarcKaufmann commented on July 21, 2024

I was wrong, it doesn't look like it was about sending emails, but about setting the default value to #f for the bot-set-id field in the user schema.

@Bogdanp: The same issue might exist for the api-key field, but it is a string, and maybe deta/postgres knows to transform a default value of #f into an empty string or into null? Source (congame/components/user):

(define-schema user
  ([id id/f #:primary-key #:auto-increment]
   [username string/f #:contract non-empty-string? #:wrapper string-downcase]
   [(password-hash "") string/f]
   [(api-key #f) string/f #:nullable]
   [(role 'user) symbol/f #:contract (or/c 'user 'bot 'api 'admin)]
   [(verified? #f) boolean/f]
   [(verification-code (generate-random-string)) string/f #:contract non-empty-string?]
   [bot-set-id integer/f #:nullable]
   [(created-at (now/moment)) datetime-tz/f]
   [(updated-at (now/moment)) datetime-tz/f])

from congame.

Bogdanp avatar Bogdanp commented on July 21, 2024

Yeah, I made a mistake here when I provided the default since nullables default to sql-null already. The api-key field doesn't have this problem because the pre-persist-hook ensures there's always a string in that field:

  #:pre-persist-hook
  (lambda (u)
    (define user-with-key
      (cond
        [(user-api-key u) u]
        [else (set-user-api-key u (generate-api-key u))]))
    (set-user-updated-at user-with-key (now/moment))))

from congame.

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.