Giter Site home page Giter Site logo

endo's Introduction

Endo

Endo is a library containing database schema reflection APIs for your applications, as well as implementations of queryable schemas to facilitate custom database reflection via Ecto.

See the official documentation for Endo.

Installation

This package can be installed by adding endo to your list of dependencies in mix.exs:

def deps do
  [
    {:endo, "~> 0.1.0"}
  ]
end

Contributing

We enforce 100% code coverage and quite a strict linting setup for Endo.

Please ensure that commits pass CI. You should be able to run both mix test and mix lint locally.

See the mix.exs to see the breakdown of what these commands do.

endo's People

Contributors

vereis avatar tomasz-tomczyk avatar

Stargazers

Max Gorin avatar Hissssst avatar Linus De Meyere avatar Simon Hansen avatar Ken Lynch avatar Rob McKinnon avatar  avatar Brian van Burken avatar

Watchers

Kate Hedgpeth Leahy avatar Sean M. Hoffman avatar Sam Ginn avatar  avatar Aaron Summers avatar

Forkers

mhmtarif

endo's Issues

Allow to specify custom schema name

Current behaviour

Currently Endo hard-codes the schema name to "public":

from(x in __MODULE__, as: :self, where: x.table_schema == "public")

However, sometimes the application may use a schema with a different name.

Connection prefixes in Ecto

Ecto calls those are called "connection prefixes" and there are two ways to set them.

  1. By setting a global connection_prefix

With the help of the after_connect callback as documented in Ecto:

https://hexdocs.pm/ecto_sql/Ecto.Adapters.Postgres.html#module-after-connect-callback

  1. By setting a per-query and per-struct prefix

https://hexdocs.pm/ecto/multi-tenancy-with-query-prefixes.html#per-query-and-per-struct-prefixes

Example:

MyApp.Repo.all(Sample, prefix: "a_custom_schema_prefix")

Suggestion

It would be great if Endo supported querying schemas other than "public".

One possibility would be allowing to configure a global table schema that would overwrite the default "public" with a config:

config :endo, table_schema: "my_custom_schema_other_than_public"

Or (and) to mimic the Ecto API, for example:

Endo.list_tables(MyApp.Repo, prefix: "my_custom_schema_other_than_public")

Error when trying to list_tables

Installed Endo for the first time and got this (list_tables without any filters, running Postgres 12):

** (Postgrex.Error) ERROR 42803 (grouping_error) column "p1.indrelid" must appear in the GROUP BY clause or be used in an aggregate function

(endo 0.1.17) lib/endo/adapters/postgres.ex:37: anonymous fn/2 in Endo.Adapters.Postgres.list_tables/2

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.