Git Product home page Git Product logo

laravel-pg-extensions's People

Contributors

cugrif avatar danieljaniga avatar dependabot[bot] avatar flemeur avatar fuwasegu avatar githomesphp avatar kentaroutakeda avatar kosadchiy avatar kvatra avatar lazeevv avatar mpyw avatar pvsaintpe avatar qem19 avatar siketyan avatar zlob avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-pg-extensions's Issues

Extending Schema for supporting triggers

What parameters should be able to customize:

  • Name
  • Body SQL-statement
  • Declaring variables
  • Language
  • Event (BEFORE / AFTER)
  • Action (INSERT / UPDATE / REMOVE)

How it can be used:

Schema::table('table', function (Blueprint $table) {
   ...
   $table->createTrigger($name)
      ->before() // or ->after() // and by default 'BEFORE'
      ->event('INSERT') // or ->event(['INSERT', 'UPDATE']) // and by default INSERT
      ->language() // by default 'plpgsql'
      ->declare([
         'delta_time_key' => 'integer',
        'delta_amount_sold' => 'numeric(15,2)',
     ]) // and by default is empty []
     ->body($statement, $bindings = []) // and by default body is empty, $bindings is empty
  ;

});

Cannot resolve PostgresConnection in Laravel11.x

As per pull request #48864 in Laravel, Laravel has abandoned its dependency on DBAL (Database Abstraction Layer) during the migration to 11.x.
In the process, methods related to Doctrine that were implemented in Illuminate\Database\Connection::class have also been removed.
Although this library was recently updated to support Laravel 11.x and its major version was bumped to 6, it still seems to be using methods like DB::registerDoctrineType(), which suggests that it has not actually followed the changes made in Laravel 11.x.

The issue is that non-existent methods continue to be called from the DB Facade, causing the resolution of the Connection to recurse infinitely, which leads to the processing getting stuck.

Thanks.

Add using statement

I trying to change column type and convert columns values.
I can't put USING statement in blueprint methods.

Sample SQL request:

#title is varchar
ALTER TABLE posts ALTER COLUMN title TYPE json USING  ('{"en":"' || title || '"}')::json

i can now only put it in DB::statement . : (

i want get something like following:

Schema::table('posts', function (Blueprint $table) {
    $table->json('title')->using($expression)->change();
 });

Partitions Error

Hi! When a set a pg partition like this:

Schema::table('pedidos', function (Blueprint $table) {
            $table->attachPartition('data_emissao')->range(
                [
                    "from" => "2010-01-01",
                    "to"   => "2010-12-31"
                ]
            );
        });

i give this error:
SQLSTATE[42P17]: Invalid object definition: 7 ERROR: table "pedidos" is not partitioned (SQL: alter table "pedidos" attach partition data_emissao for values from (2010-01-01) to (2010-12-31))

Arrays

Is any plans to implement array types ?

Fix ChangeColumn Compiler for support using Expression in default()

How to use, example:

Schema::table('some_table', function (Blueprint $table) {
   $table->integer('code')
        ->default(DB::raw("''::character varying"))
       ->change();
   ...
   $table->bigInteger('id')
        ->default(DB::raw("nextval('some_table_id_seq'::regclass)")
        ->change();
});

Now there are some problems, since AbstractPlatform generates incorrect SQL for ALTER TABLE, ex.:

Schema::table('some_table', function (Blueprint $table) {
   $table->integer('code')
        ->default(DB::raw("''::character varying"))
       ->change();
});

Results:

ALTER TABLE some_table ALTER COLUMN code SET DEFAULT '\'\'::character varying'::character varying

Expected:

ALTER TABLE some_table ALTER COLUMN code SET DEFAULT ''::character varying

Depends on: doctrine/dbal#3626

I'm waiting for the merge request to be merged to continue working...

Postgres supports multiple insert returning ID, but Laravel doesn't support that

When we batch insert into postgres database table, we can get an option by postgres to return all the inserted IDs.

INSERT INTO ycode_entities (name, email, created_at) VALUES [(...)]
RETURNING id

The above statement will retrieve all the Id that has been inserted in bulk.
Unfortunately, there is no option to do this natively without using raw query in Laravel since insertMany() doesn't return ids or any primary key data.

Is there a way to extend this functionality using laravel-pg-extensions or by any means?

After including package tries to connect to db ?

Due to how my environment is setup the host name wont be reachable, ideally it shouldn't try to connect at all when discovering the package.

Nothing to install, update or remove
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> rm -f laravel/bootstrap/cache/services.php
> rm -f laravel/bootstrap/cache/packages.php
> @php laravel/artisan package:discover

   Doctrine\DBAL\Driver\PDOException

  SQLSTATE[08006] [7] could not translate host name "pgbouncer" to address: Temporary failure in name resolution

  at vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31
     27▕             parent::__construct($dsn, (string) $user, (string) $password, (array) $options);
     28▕             $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [PDOStatement::class, []]);
     29▕             $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     30▕         } catch (\PDOException $exception) {
  ➜  31▕             throw new PDOException($exception);
     32▕         }
     33▕     }
     34▕
     35▕     /**

  1   [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()

      +15 vendor frames
  17  laravel/app/Providers/DatabaseServiceProvider.php:42
      Illuminate\Database\Connection::__construct()

PDO Read or Write connection

I have a problem, I use master and slave postgres. master is located far from the backend, and slave is nearby. This package is automatically connected by default to the master - write connection, thereby increasing the request time by more than 2 seconds! How can I fix this? Please help me.

After remove umbrellio/laravel-pg-extensions, all ok!

stack trace:
PDO::__construct
Illuminate\Database\Connectors\Connector::createPdoConnection
Illuminate\Database\Connectors\Connector::createConnection
Illuminate\Database\Connectors\PostgresConnector::connect
Illuminate\Database\Connectors\ConnectionFactory::Illuminate\Database\Connectors{closure}
call_user_func
Illuminate\Database\Connection::getPdo
Illuminate\Database\Connection::getDoctrineConnection
Umbrellio\Postgres\PostgresConnection::getDoctrineConnection
Illuminate\Database\Connection::getDoctrineSchemaManager
Illuminate\Database\Schema\Builder::registerCustomDoctrineType
Umbrellio\Postgres\PostgresConnection::Umbrellio\Postgres{closure}
Illuminate\Support\Collection::each
Umbrellio\Postgres\PostgresConnection::registerExtensions
Umbrellio\Postgres\PostgresConnection::useDefaultPostProcessor
Illuminate\Database\Connection::__construct
Umbrellio\Postgres\Connectors\ConnectionFactory::createConnection
Illuminate\Database\Connectors\ConnectionFactory::createSingleConnection
Illuminate\Database\Connectors\ConnectionFactory::createReadWriteConnection
Illuminate\Database\Connectors\ConnectionFactory::make

Declaration of `Umbrellio\Postgres\Schema\Builder::hasView(string $view): bool` must be compatible with `Illuminate\Database\Schema\Builder::hasView($view)`

    /**
     * Determine if the given view exists.
     *
     * @param  string  $view
     * @return bool
     */
    public function hasView($view)
    {
        $view = $this->connection->getTablePrefix().$view;

        foreach ($this->getViews() as $value) {
            if (strtolower($view) === strtolower($value['name'])) {
                return true;
            }
        }

        return false;
    }
    public function hasView(string $view): bool
    {
        return count($this->connection->selectFromWriteConnection($this->grammar->compileViewExists(), [
            $this->connection->getConfig()['schema'],
            $this->connection->getTablePrefix() . $view,
        ])) > 0;
    }

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.