[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-recutils] Auto generated fields
From: |
Jose E. Marchesi |
Subject: |
[bug-recutils] Auto generated fields |
Date: |
Sun, 30 Jan 2011 21:26:05 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) |
Hi.
I just merged a branch providing support for auto-generated fields.
They are a way to for example implement auto-counters and timestamps.
A new directive is available for use in record descriptor: %auto. It
accepts a list of fields separated by blanks, and determines that those
fields shall be auto-generated when new records are inserted in the
record set.
For example, consider:
/
| %rec: Item
| %type: Id int
| %auto: Id
|
| Id: 1
| Description: this is item 1
\
If a new item is inserted using recins, and no explicit Id is specified:
$ recins -t Item -f Description -v "another item" items.rec
The newly created record will contain a unique Id:
/
| %rec: Item
| %type: Id int
| %auto: Id
|
| Id: 1
| Description: this is item 1
|
| Id: 2
| Description: another item
\
The auto-increment functionality works with fields of type 'int' and
'range'.
If %auto is used with fields of type 'date', the generated fields will
contain the current date of the system at record creation. This is
useful to implement timestamps:
/
| %rec: Item
| %type: Id int
| %type: Date date
| %auto: Id Date
|
| Id: 1
| Date: Sun Jan 30 21:24:28 CET 2011
| Description: this is item 1
\
Note that the auto-generation of the fields will be performed only if no
explicit values are specified for those fields in the recins invocation.
Aditionally, the --no-auto command line argument of recins can be used
to inhibit the generation.
Enjoy!
--
Jose E. Marchesi address@hidden
GNU Project http://www.gnu.org
- [bug-recutils] Auto generated fields,
Jose E. Marchesi <=