Esempio n. 1
0
        private List <string> GetDumpLines(string args, string tableArg, out List <PgItem> types)
        {
            List <PgItem> found  = new();
            var           result = GetDumpLines(args, tableArg, lineAction: line =>
            {
                var entry = line.FirstWordAfter("CREATE TYPE");
                if (entry != null)
                {
                    var type = new PgItem {
                        Type = PgType.Type
                    };
                    var parts = entry.Split('.');
                    if (parts.Length < 2)
                    {
                        type.Schema = "public";
                        type.Name   = entry;
                    }
                    else
                    {
                        type.Schema = parts[0];
                        type.Name   = parts[1];
                    }
                    found.Add(type);
                }
            });

            types = found;
            return(result);
        }
Esempio n. 2
0
        public List <string> GetRawTableDumpLines(PgItem table, bool withPrivileges)
        {
            var tableArg = table.GetTableArg();
            var args     = string.Concat(baseArg, " --schema-only  --no-owner", withPrivileges ? "" : " --no-acl");

            return(GetDumpLines(args, tableArg));
        }
Esempio n. 3
0
 public static string GetFileName(this PgItem item)
 {
     if (!string.Equals(item.Schema, "public"))
     {
         return($"{item.Schema}.{item.Name}.sql");
     }
     return($"{item.Name}.sql");
 }
Esempio n. 4
0
        private string GetSeqContent(PgItem seq, string args)
        {
            var tableArg = seq.GetTableArg();

            if (settings.DbObjectsRaw)
            {
                return(GetPgDumpContent($"{args} {tableArg}"));
            }
            return(new SequenceDumpTransformer(seq, GetDumpLines(args, tableArg)).BuildLines().ToString());
        }
Esempio n. 5
0
        private string GetViewContent(PgItem table, string args)
        {
            var tableArg = table.GetTableArg();

            if (settings.DbObjectsRaw)
            {
                return(GetPgDumpContent($"{args} {tableArg}"));
            }
            return(new ViewDumpTransformer(GetDumpLines(args, tableArg))
                   .BuildLines(dbObjectsCreateOrReplace: settings.DbObjectsCreateOrReplace)
                   .ToString());
        }
 public TypeDumpTransformer(PgItem item, List <string> lines) : base(lines)
 {
     this.Item = item;
 }
Esempio n. 7
0
 public static string GetTableArg(this PgItem item) => $"--table=\\\"{item.Schema}\\\".\\\"{item.Name}\\\"";