Skip to content
Branch: master
Find file History
a8m and facebook-github-bot dialect/sql: fix predicate builder on join
Summary: Pull Request resolved: #143

Reviewed By: idoshveki

Differential Revision: D18346652

fbshipit-source-id: e8c5d7eb3cefc16f52090de0d121e82cae058fc2
Latest commit 53cfcb6 Nov 6, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
ent dialect/sql: fix predicate builder on join Nov 6, 2019
README.md entc: add option to use entc as package Oct 7, 2019
entcpkg.go

README.md

entcpkg example

An example of using entc (ent codegen) as package rather than an executable.

In this example, we have a file named entc.go under the ./ent directory, that holds the configuration for the codegen:

// +build ignore

package main

import (
	"log"

	"github.com/facebookincubator/ent/entc"
	"github.com/facebookincubator/ent/entc/gen"
	"github.com/facebookincubator/ent/schema/field"
)

func main() {
	err := entc.Generate("./schema", &gen.Config{
		Header: `
			// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
			// This source code is licensed under the Apache 2.0 license found
			// in the LICENSE file in the root directory of this source tree.

			// Code generated (@generated) by entc, DO NOT EDIT.
		`,
		IDType: &field.TypeInfo{Type: field.TypeInt},
	})
	if err != nil {
		log.Fatal("running ent codegen:", err)
	}
}

As you can see, the file is tagged with // +build ignore in order to not include it in the ent package. In order to run the codegen, run the file itself (using go run) or run go generate ./ent. The generate.go file holds the go run command:

package ent

//go:generate go run entc.go

The generate.go file is preferred if you have many generate pragmas in your project.

You can’t perform that action at this time.