Giter Club home page Giter Club logo

pg-wrapper's People

Contributors

sad-spirit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jeijei4

pg-wrapper's Issues

Improve exceptions hierarchy

InvalidQueryException should probably be renamed to DatabaseException: current name is misleading as the query may be perfectly valid but failing for whatever reason. It may be a good idea to follow Doctrine DBAL by providing specialized subclasses of DatabaseException and create them based on SQLSTATE field.

Need to check what is being returned by pg_last_error() if connection to the DB is lost and throw ConnectionException in that case.

The methods are too liberal to throw InvalidArgumentException for all kinds of errors, some of which are essentially runtime, e.g. in ResultSet

  • offsetSet() and offsetUnset() should probably throw an instance of BadMethodCallException
  • checkFieldIndex() should probably throw an instance of OutOfBoundsException for missing field index / name (fetchAll() probably too)

in PreparedStatement bindValue() and bindParam() should throw an instance of OutOfRangeException (we can't check that the value is within the count of actual placeholders, but we can at least check that it is >= 1)

in DefaultTypeConverterFactory [improved, see #7] method getConverterForTypeOid() should probably never throw exceptions at all while getConverterForTypeSpecification() should throw a specialized subclass of InvalidArgumentException for missing converters.

Drop support for PHP versions older than 7.2

Up the dependency in composer.json

Change .travis.yml to test on PHP 7.2+ only

Drop version checks in code (e.g. JSONTest::testJSONBigintAsString()) and workarounds (e.g. in JSONConverter)

Update for PSR-12 coding standards

As I targeted PEAR coding standards (without anal PHPDoc) there isn't much to do, mostly

  • Rename _prefixed private properties and methods
  • Fix multiline function calls
  • Fix indentation in switch constructs

One idiotic problem with that CS is that blank line is not allowed before else / elseif:

if (is_numeric($native)) {
    return $native;

} elseif (0 === strcasecmp($native, 'NaN')) {
    return NAN;

} else {
    throw TypeConversionException::unexpectedValue($this, 'input', 'numeric value', $native);
}

results in

ERROR | [x] Blank line found at end of control structure

Need to think of the options here.

Drop support for mbstring.func_overload

Setting deprecated in PHP 7.2 and will be removed in PHP 8

This should give a speedup for type converters by removing unneeded indirections via call_user_func()

Split TypeConverterFactory::getConverter()

...into several methods:

  • getConverterForTypeOid() - this one will not work without connection and will not throw an exception if a specific converter cannot be found, returning something like StubConverter instead.
  • getConverterForTypeSpecification() - this one will throw exceptions if a specific converter is not found
    It's highly unlikely that anyone will submit database type oid as type specification for execute() and friends.

Also it may be a good idea to add

  • getConverterForValue() - similar to what Connection::guessOutput() currently does but with a means to register the specific class to look for. E.g. registerConverter() registers IntervalConverter and the fact that it would like to convert all instances of DateInterval by default.

guessOutput() knows too much about implementation details and will not work correctly with StubConverterFactory currently. Needs to be removed.

Json serialization

Hi, thanks for your library it's really helping.
i have a question, i want to json_encode a Point but i was getting an empty array, is there any other way then to set my own PointConverter and Point type. Thanks.

Drop support for PostgreSQL versions older than 9.4

Drop version checks in code (e.g. in ByteaConverter and `DefaultTypeConverterFactory::_loadTypes())

Probably throw an Exception in Connection::connect() if server version is below 9.2 (we don't actually depend on features of later versions)

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.