Git Product home page Git Product logo

Comments (4)

wendynovianto avatar wendynovianto commented on July 28, 2024

I think the problem is not on the convention structure class, instead it's on the result class itself, when joining the table. Here's what I did and so far it looks ok, though I'm not sure whether it solves the root of the bug or not. Please advice!

protected function createJoins($val) {
    $return = array();
    preg_match_all('~\\b([a-z_][a-z0-9_.:]*[.:])[a-z_*]~i', $val, $matches);
    foreach ($matches[1] as $names) {
        $parent = $this->table;
        if ($names != "$parent.") { // case-sensitive
            preg_match_all('~\\b([a-z_][a-z0-9_]*)([.:])~i', $names, $matches, PREG_SET_ORDER);
            foreach ($matches as $match) {
                list(, $name, $delimiter) = $match;
                $table = $this->notORM->structure->getReferencedTable($name, $parent);
                $column = ($delimiter == ':' ? $this->notORM->structure->getPrimary($parent) : $this->notORM->structure->getReferencedColumn($name, $parent));
                $primary = ($delimiter == ':' ? $this->notORM->structure->getReferencingColumn($table, $parent) : $this->notORM->structure->getPrimary($table));
                $return[$name] = " LEFT JOIN $table" . ($table != $name ? " AS $name" : "") . " ON $parent.$column = $name.$primary"; // should use alias if the table is used on more places
                $parent = $name;
            }
        }
    }
    return $return;
}

from notorm.

wendynovianto avatar wendynovianto commented on July 28, 2024

I wonder whether this issue had been fixed yet?

$primary = ($delimiter == ':' ? $this->notORM->structure->getReferencingColumn($parent, $table) : $this->notORM->structure->getPrimary($table));

I change getReferencedColumn to getReferencingColumn.
Is the fix above actually fix the problem or not?

Please advice.

from notorm.

wendynovianto avatar wendynovianto commented on July 28, 2024

I think this is more complicated than it does.

Anybody can help out?

from notorm.

wendynovianto avatar wendynovianto commented on July 28, 2024

I tried this, but haven't actually tested it fully.

    protected function getColumnFromTable($name) {
        if ($this->table != '%s' && preg_match('(^' . str_replace('%s', '(.*)', preg_quote($this->table)) . '$)', $name, $match)) {
            return $match[1];
        }
        return substr($name, strlen($this->prefix));
    }

Basically I change return $name; into return substr($name, strlen($this->prefix));.

Please correct me if I'm wrong.

from notorm.

Related Issues (20)

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.