Database-Abstraction
view release on metacpan or search on metacpan
Results come from the slurp cache when available.
Throws an error if the column does not exist (slurp mode) or if AUTOLOAD
has been disabled with `auto_load => 0`.
#### Pseudocode
```perl
1. Extract column name from $AUTOLOAD; guard on DESTROY.
2. Croak if auto_load => 0.
3. Validate $column against /^[a-zA-Z_][a-zA-Z0-9_]*$/.
4. If data is slurped:
a. List context, no params -> map column over all rows (exists guard).
b. entry-only param -> direct hash lookup (exists guard).
c. No params, scalar -> first value in hash.
d. no_entry set -> scan array for matching key/value pair.
e. Other params -> scan keyed hash for matching column.
5. If not slurped, build SQL:
- List: SELECT column FROM table [WHERE ...] ORDER BY column
- Scalar: SELECT DISTINCT column FROM table [WHERE ...] LIMIT 1
6. Check cache; return on HIT.
7. prepare_cached + execute; fetch result.
8. Store in cache; fixate; return.
```
## Author
Nigel Horne, `<njh at nigelhorne.com>`
## Support
This module is provided as-is without any warranty.
Please report any bugs or feature requests to `bug-database-abstraction at rt.cpan.org`,
or through the web interface at
[http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Database-Abstraction](http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Database-Abstraction).
I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
## Messages
The table below lists every error that the module can croak or carp, what
triggers it, and how to resolve it.
- `_Class_: abstract class`
Direct instantiation of `Database::Abstraction` was attempted.
Create a subclass and instantiate that instead.
- `_Class_: where are the files?`
Neither `directory` nor `dsn` was supplied to `new()`.
- `_Class_: _/path_ is not a directory`
The `directory` argument exists on disk but is not a directory.
- `_Class_: cannot connect: _$DBI::errstr_`
DBI failed to connect to the given `dsn`. Check credentials and host.
- `Can't find a file called '_name_' for the table _T_ in _dir_`
None of the probe extensions (`.sql`, `.sqlite`, `.sqlite3`, `.psv`, `.tsv`, `.csv`, `.xlsx`, `.db`, `.xml`)
matched in `directory`.
- `_Class_: prepare failed: _$errstr_`
`prepare_cached()` returned false. Usually a syntax error in an internally
built query; file a bug if you see this from a normal API call.
- `_build_where_conditions: unsafe column name '_name_'`
A criteria key contained characters outside `[A-Za-z0-9_.]`.
This is a SQL-injection guard. Use only valid SQL identifier characters.
- `join: missing "table"` / `join: missing "on" condition`
A join spec hashref is incomplete. Both `table` and `on` are required.
- `Invalid JOIN type: _TYPE_`
`type` in a join spec was not one of `INNER LEFT RIGHT FULL CROSS`.
- `_Class_: Unknown column _col_` / `_Class_: AUTOLOAD disabled`
An AUTOLOAD call was made for a column that does not exist, or AUTOLOAD
was disabled with `auto_load => 0`.
- `Usage: set_logger(logger => $logger)`
`set_logger()` was called without a `logger` argument.
- `Usage: execute(query => $query)`
`execute()` was called without a `query` argument.
- `XML slurp: _..._ is not yet supported`
The XML file structure is too complex for slurp mode.
Use `max_slurp_size => 0` to force the DBI/XMLSimple SQL path.
- `_Class_: _method_ is meaningless on a NoSQL database`
A relational method (`selectall_arrayref`, `count`, `execute`, etc.)
was called on a BerkeleyDB backend, which only supports key-value lookup
via `fetchrow_hashref`.
- `_Class_: aggregate: 'measures' must be a non-empty arrayref`
`aggregate()` was called without a `measures` arrayref, or with an empty one.
- `_Class_: aggregate: measure must be a hashref, got _ref_`
An element of the `measures` arrayref is not a hashref.
- `_Class_: aggregate: unknown measure function '_fn_'`
`fn` must be one of `sum`, `avg`, `min`, `max`, `count`, `count_distinct`,
`median`, `stddev`.
( run in 1.061 second using v1.01-cache-2.11-cpan-3f962061493 )