Project

General

Profile

Actions

Feature #1205

open

DEFAULT values (db serverside) for table fields

Added by denis talakevich over 12 years ago. Updated about 12 years ago.

Status:
InProgress
Priority:
Normal
Assignee:
Target version:
-
Start date:
03/21/2012
Due date:
% Done:

0%

Estimated time:

Description

Adding a field flag which causes Wt::Dbo to generate "insert" and "update" statements with DEFAULT value to current field (database serverside).

For example if we have table like

create table Test_table (id int PRIMARY KEY, name text NOT NULL, quota int DEFAULT 100 NOT NULL, create_date DEFAULT now());

with using of Dbo::ptr cause to generating statements like

insert into "Test_table" ("id", "name", "quota", "create_date") values ($1, $2, $3, $4) returning "id"
bind: $1 = default, $2 = 'qweqwe', $3 = deafult, $4 = default

detailed log of events:

LOG:  statement: start transaction
LOG:  duration: 0.229 ms
DEBUG:  parse SQL0x2b157f003113C398: insert into "Test_table" ("id", "name", "quota", "create_date") values ($1, $2, $3, $4) returning "id"
LOG:  duration: 2.226 ms  parse SQL0x2b157f003113C398: insert into "Test_table" ("id", "name", "quota", "create_date") values ($1, $2, $3, $4) returning "id"
DEBUG:  bind <unnamed> to SQL0x2b157f003113C398
LOG:  duration: 0.101 ms  bind SQL0x2b157f003113C398: insert into "Test_table" ("id", "name", "quota", "create_date") values ($1, $2, $3, $4) returning "id"
DETAIL:  parameters: $1 = default, $2 = 'qweqwe', $3 = deafult, $4 = default
LOG:  execute SQL0x2b157f003113C398: insert into "Test_table" ("id", "name", "quota", "create_date") values ($1, $2, $3, $4) returning "id"
DETAIL:  parameters: $1 = default, $2 = 'qweqwe', $3 = deafult, $4 = default
LOG:  duration: 1.829 ms
LOG:  statement: commit transaction

when "default" flag is ON for some fields, value of this fields must be ignored (for any types and any values) to prevent misunderstandings.

Same for generating "update" statement with use Dbo::ptr::modify()

Actions #1

Updated by Koen Deforche over 12 years ago

  • Status changed from New to InProgress
  • Assignee set to Koen Deforche
  • Target version set to 3.2.2

The following is a hint on how this might be solved:

http://www.mkyong.com/hibernate/hibernate-dynamic-insert-attribute-example/

Regards,

koen

Actions #2

Updated by Koen Deforche over 12 years ago

  • Target version changed from 3.2.2 to 3.2.3
Actions #3

Updated by Koen Deforche about 12 years ago

  • Target version deleted (3.2.3)
Actions

Also available in: Atom PDF