Packages / openSUSE Tumbleweed / Source / perl-Mojo-SQL

Source Package: perl-Mojo-SQL (0.20.0-1.3)

Safely generate and compose SQL statements

Mojo::SQL safely generates and composes SQL statements. To prevent SQL injection attacks, every '?' in the input becomes a placeholder in the generated query, with the corresponding value bound to it. Partial statements can be composed recursively to build more complex queries. Literal question marks can be escaped with '??'. use Mojo::SQL qw(sql); my $role = 'admin'; my $partial = sql('AND role = ?', $role); my $name = 'root'; my $query = sql('SELECT * FROM users WHERE name = ? ?', $name, $partial)->to_query; Make partial statements optional to dynamically generate 'WHERE' clauses. my $optional = $foo ? sql('AND foo IS NOT NULL') : sql(''); my $query = sql('SELECT * FROM users WHERE name = ? ?', 'sebastian', $optional)->to_query; If you need a little more control over the generated SQL query, you can also bypass safety features with "sql_unsafe". But make sure to handle unsafe values yourself with appropriate escaping functions for your database. For PostgreSQL there are "escape_literal" and "escape_identifier" functions included with this module. use Mojo::SQL qw(sql sql_unsafe escape_literal); my $role = 'role = ' . escape_literal('power user'); my $partial = sql_unsafe 'AND ?', $role; my $name = 'root'; my $query = sql('SELECT * FROM users WHERE name = ? ?', $name, $partial)->to_query; For databases that do not support numbered placeholders like '$1' and '$2', you can set a custom character with the 'placeholder' option. my $query = sql('SELECT * FROM users WHERE name = ?', 'root')->to_query({placeholder => '?'});

Package information

Homepage
[https://metacpan.org/release/Mojo-SQL]
License
MIT
Downstream package maintainer
Unknown: not reported in the indexed source

The following binary packages are built from this source package:

Known vulnerabilities

No matching advisories in the tracked sources.

Last synced:

[CVE catalog]

Sources

  • Authoritative source; repository metadata signature verified

    Signature evidence

    tumbleweed-oss-multiarch:4db10cdde3ad82c7e22be35753c9e164b4bdd30f92db4aee17a0d4c94c5f902f

    Repository-signature verification record
    Signed-object SHA-256
    4db10cdde3ad82c7e22be35753c9e164b4bdd30f92db4aee17a0d4c94c5f902f
    Signer fingerprint
    AD485664E901B867051AB15F35A2F86E29B700A4
    Keyring revision
    opensuse-project-signing-key.asc
    SHA-256 b5745739ebfb95b25b8e810f9bcb847fe750ccda598bd85f02f0e974599a6d7e
    Tool and policy
    gpgv (GnuPG) 2.4.9
    openfactory-software-catalog-signature-v1
    Verification time
    Sep 1, 2026
    Repository metadata hash linkage
    Result
    Recorded as verified; digest details unavailable